RSSAmplifier

Blog

Attila Oláh

Full-time dad, part-time web developer.

attilaolah.euRSS feed ↗42 posts

Latest posts

Rotating Earth in Godot 3.4

In the previous tutorial, Rendering Earth in Godot 3.4 , I showed how to make a simple Earth model in Blender and import it to Godot. In this post, we’ll explore how to rotate the globe, thus making our “game” interactive. This is how the node tree and resource tree should look like (adjusted from the previous post to follow Godot’s file naming conventions ). The uneverse.tscn file contains our…

Rendering Earth in Godot 3.4

In a previous post, Using Environment Textures in Blender 2.91 , I used an environment texture to render a virtual globe : Then, in a follow-up post, Baking Environment Textures in Blender 2.91 , I showed how to bake the environment texture onto a UV image. This is useful for example when exporting the globe to a game engine like Godot, which can work with UV maps but not with environment…

Baking Environment Textures in Blender 2.91

This tutorial will demonstrate how to re-project Equirectangular images to cube maps in Blender, using a technique called Baking. Before you get started, you should set up your material using an environment texture, as described in the previous tutiorial, Using Environment Textures in Blender 2.91 . The material should look something like this in the Shading workspace: …and your default cube…

Using Environment Textures in Blender 2.91

This tutorial will demonstrate how to use equirectangular environment textures in Blender. I’m going to use version 2.91 just because that happens to be the latest stable version. As an example, we’re going to make an “Earth” texture. Before we dive in, we need to download some high-res textures: I got mine from a Google search: I downloaded the “Explorer Base Map”, published September 1, 2020.…

My cURL alias

This is one of the most common aliases I use. Tools curl(1) : alias c="curl -s --dump-header /dev/stderr" xargs(1) jq

Cross-compiling CGO to ARM

This is a story about a a piece of Go code that wanted to be cross-compiled for the Raspberri Pi. From a private repo. On Wercker. With C/CGO files. And link it against libbluetooth . Requirements Cross-compile to ARM. Target the Raspberry Pi . Include C source files. Needs cgo . Link against libbluetooth . Needs custom ldflags . Do all this on Wercker . Steps I go through Read Dave Cheney ’s blog…

JSON and struct composition in Go

Say you are decoding a JSON object into a Go struct. It comes from a service that is not under your control, so you cannot do much about the schema. However, you want to encode it differently. You could go wild with json.Marshaler , but it has some drawbacks: complexity : adds lots of extra code for big structs memory usage : must be careful not to do needless allocations To be fair, in most cases…

A simple but powerful zsh prompt

Over the years, I’ve been changing my bash prompt every now and then. Since I switched to zsh last year, and started using oh-my-zsh , I’ve slowly put together the perfect prompt for my needs. Here’s how it looks right now (with extra-large font size for better visibility): Parts of the left prompt, from left to right: 1 z shows that there is one background job ( vim ), suspended with Ctrl + Z…

Quick security checklist

This is intended to be a short list of things to check before you go publish a website or web app (or really, anything that interacts with a browser). It starts with the easy things and continues with less obvious stuff. It is in no way complete. Use HttpOnly cookies Pretty much eliminates XSS -based session hijacking ✓ Easy to set up on most servers ✓ Does not completely eliminate XSS attacks ✗…

Evil ELFs

In this post I am going to demonstrate how to easily find out what an evil ELF is doing to your system. This can be useful if you have one that is making secure network connections and you want to have a closer look… Or just for fun. Linked library dependencies and ldd The easiest to start with are linked library dependencies. In our example: $ ldd ./evil-elf [ …] libcurl.so.4 =>…

JSON decoding in Go

Incidentally, decoding JSON data (or really, almost any data structure) is really easy in Go (golang). We simply call json.Unmarshal(…) and boom! We have nice data structures. Well, except if our input source is not very well defined (meaning not strictly typed ). Objects with loose schema Take this example. We want to decode a JSON object that looks like this: { "author" : "attilaolah@gmail.com"…

Convert HTML files to PNG

For some stupid reason I ended up having to convert a whole lot of HTML files to images. Not wanting to waste space, the plan was to compress the files as much as possible without loosing too much quality. So here’s how to do it: for f in * .html ; do wkhtmltoimage -f png $f $f .png mogrify -trim $f .png pngquant --speed 1 $f .png --ext .png.o mv $f .png.o $f .png done Here’s what each line does:…

Vim essentials

Here is a list of Vim scripts I picked up in the past few years that I find very useful. All of them can be found as submodules in my dotvim repo . I am attaching my own rating to the scripts, but these aren’t really objective. They are merely an indication how much I ended up using the scripts. For example, vim-fugitive is so damn powerful it deserves a sixth star, but I just prefer to use git…

A Walter számok halmaza

Ajánlom minden olyan ismerősöm figyelmébe, aki azt hiszi, hogy a gyök kettő nem is igazi, az \(i\) pedig egyáltalán nem létezik. Szóval kezdett elegem lenni abból, hogy egyesek néhány sör után elkezdik támadni a számukra ismeretlen matematikai fogalmak sokaságát azzal az érvvel, hogy olyan nincs is . Igen, a gonosz matematikusok kitalálnak mindenféléket csak azért, hogy ezzel is bosszantsák a…

Why back-end programming is hard

Or to put it in another way, why is font-end programming way easier. I have a very simple theory about this matter. Because of the difference in what people consider being a product in each case, the process of writing and maintaining front-end code often becomes a lot different than writing a back-end. The way a manager would look at a client app is something along these lines: developer writes…

To lint or not to lint

In general it is always a good idea to run static checkers through the code. It catches some obvious mistakes and helps maintain a readable code base — at least most of the time. But some checkers are quite aggressive, or some rules may be too outdated or simply don’t match the preferred coding style of the programmer. Nevertheless, here are my two cents on linters and other static checkers:…

Coding style

Today’s rant is about coding style , readability and code review. It happened to me more than once that I wrote some code that looked more or less like this (simplified to avoid disclosure): 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class Author ( User ): """Book author.""" def reviews ( self , limit = None ): """Reviews by the author. Usage: >>> for review in book.author.reviews(5): ... print(review) """…

Online nyelvtanulás, fordítás

Az utóbbi néhány évben egyre több dolgot és egyre hatásosabban lehet megtanulni az interneten. Nem is olyan rég indult a Khanacademy , nemsokra rá több egyetem is indított online ingyenes tanfolyamokat , majd tavaly februárban +Sebastian Thrun , +David Stavens , és +Mike Sokolsky megalapították a Udacity -t. Nemrég azonban egy új érdekességre lettem figyelmes: Duolingo . Duolingo A Duolingo az…

HTC Desire network unlock guide

If under Linux or XP, install VirtualBox (or some other virtualisation tool) ( emerge virtualbox for Gentoo) get a Windows 7 ISO (no, wine will not work) (no, XP won’t work either, at least the 64-bit version has troubles with the the adb interface drivers) install Windows 7 in VirtualBox Then, connect the Desire (make sure USB debugging is enabled) install HTC Sync , that will install the Android…

HTC Desire hálózatfüggetlenítése

Ha Linuxban vagy XP-ben vagy, telepíts egy VirtualBox -ot (vagy valami hasonlót) ( emerge virtualbox Gentooban) szerezz egy Windows 7 ISO-t (sajnos a jó öreg wine itt nem fog segíteni) (XP sem jó, legalább is a 64-bites verzió nem akarja telepíteni az illesztőprogramokat) telepíts Windows 7-et VirtualBox-ban Ezután csatlakoztast a Desire-t (a telefonon az USB fejlesztést be kell kapcsolni)…

WAT and the principle of least astonishment

I came across this video while reading a question on StackExchange programmers about the Principle of Least Astonishment .

irssi and camper_van

Recently I’ve come across a ruby irc server called camper_van . What it does is pretty simple: it communicates with Campfire while acting as an IRC server . That, combined with irssi makes it much more fun to use Campfire for work . The following is a simple script that starts the server (if not already running) and then opens up irssi in a new gnome-terminal session. The second file is an example…

HTTP DELETE and Sencha Touch

I’ve recently learned that App Engine chokes on HTTP DELETE requests that contain a request body. While developing locally, everything works just fine, but when deployed, the production server drops these “malformed” requests with a “400 Bad Request” status line, so they don’t even reach the application in the WSGI pipeline . After reading the specs I couldn’t find where it would state that a body…

Prevent Chromium opening all files with Firefox

Chromium opens downloaded files using xdg-open . Problem is, xdg-open doesn’t work correctly with awesome (and also doesn’t support a number of other, non-mainstream wms.) The piece of code responsible for detecting the desktop environment: detectDE () { if [ x " $KDE_FULL_SESSION " = x "true" ] ; then DE = kde ; elif [ x " $GNOME_DESKTOP_SESSION_ID " != x "" ] ; then DE = gnome ; elif ` dbus-send…

Debugging the fglrx driver

A broken Sapphire Radeon HD 4850 somehow ended up in my possession. I didn’t know what was the problem, so I tried to plug it in in a mobo I just had lying around, running the nightly oneiric . The card showed up fine in lspci . I didn’t try using it with the open-source drivers, as I’m not interested in putting a display on it. Instead I wanted to play around a little with OpenCL , so I went for…

Python modular exponentiation by squaring

Exponentiation of large numbers can easily be implemented using exponentiation by squaring , which greatly reduces the number of steps it is needed for a given imput. Computing large exponents modulo a number is even faster and requires less memory, as it reduces the size of the resulting integer. The following implementation works for both Python 3 and python 2 (although in Python 3 it will run…

2011 Buschenschanksprint

My lovely girlfriend now wife and I have attended the first four days of Buschenschanksprint 2011 , in the beautiful hills and vineyards of Berghausen , in Styria , Austria . We had some great time, visited some Buschenschänke , and, of course, wrote a lot of code. I mostly worked on code that was related to the project I’m working on. Nevertheless, during the sprint we’ve implemented a new…

Yet another pure CSS progress bar

Inspired by Ivan Vanderbyl’s implementation , I also put together a progress bar, in pure CSS. The transition of the blue bar is also done with CSS, only the text is being updated with JavaScript. The animation is done using JavaScript to make sure it synchronizes nicely with the percentage text. It is also possible to animate it with pure CSS though. The full code is in one simple HTML file,…

Drawing 3D maps with HTML5 canvas

Today I had some free time, so I played around with the OpenStreetMap API. It turns out it’s quite easy to draw 3D-looking buildings on a canvas. After an hour or two of coding, I was able to render actual buildings from the OSM database: Buildings rendered on a canvas On the above picture, red buildings are “primary” ones (i.e. ones with an address or a house number), while the grey ones are…

Factoring 100 million digit numbers

Yesterday I figured I’ll try to factor the first few numbers greater than 10¹⁰⁰⁰⁰⁰⁰⁰⁰ (or at least find their smallest divisors). The idea was to see how hard it is to find the divisors of the first few hundred 100,000,001-digit numbers. I took a pretty simple approach: for each prime number p, calculate 10¹⁰⁰⁰⁰⁰⁰⁰⁰%p (the remainder after dividing by p). Then I used the result to create a partial…

Compositing in awesome

A while ago I wrote two widgets for awesome . Later on I’ve added a little more look&feel to my awesome desktop. Compositing Very easy, via xcompmgr . I don’t like the huge default shadows (nor pretty much any of the default settings), so I start it from my rc.lua like this: awful . util . spawn ( "nautilus -n" ) awful . util . spawn ( "xcompmgr -c -C -f -F -D 2.5 -l -2 -t -2 -r 2 -o 0.25" ) Note…

Python exception weirdness

This may have been obvious to others, but I have just found out that in Python, when Exceptions get raise d, they are converted to strings. That is: >>> class C(object): ... __str__ = lambda s: '<C: str>' ... __repr__ = lambda s: '<C: repr>' >>> c = C() >>> exc = Exception(c) >>> exc Exception(<C: repr>,) >>> repr(exc) 'Exception(<C: repr>,)' >>> str(exc) '<C: str>' And now comes the interesting…

2011 a][rtsprint Vienna

The artsprint was a one-week Python / Pyramid / Node sprint at the ]a[ Academy of Fine Arts , Vienna . 27 Participants were mostly BDA people, with the addition of some other Python enthusiasts. We’ve been working on a stack of libraries that most of use on a daily basis, focusing mainly on writing documentation, fixing tests, and converting the whole stack from repoze.bfg to Pyramid. And we even…

2011 Startup Weekend Brussels

The Startup Weekend seems great so far. Running surveys, advertizing, planning a business, playing the Kinect , beer, mandarins , lots of interesting people , and planning various cow usage. So far not much coding though. I’ll just have to make up for it next week at artsprint.

Merging mkv files

A while ago I was looking for a way to merge two separate .mkv files (left and right views of a stereoscopic, 3D movie) into one file, to get a side-by-side or top-bottom view. Since back then I didn’t get any answer on SuperUser I’ve got an answer , I figured I might just look into it myself, google it, read a few man pages, and then write it down for the rest of the world. I’m not encouraging…

Two simple widgets for awesome

The two widgets next to the system tray: Awesome WM widgets Battery monitor This one is pretty simple, based on this wiki page : (requires acpitools ): The nice thing about it is that it changes its color dynamically (and linearly). 0% battery = #FF0000 , 100% = #00FF00 . CPU temperature monitor Based on the same code, looks very similar to the battery widget: Update I’ve updated the temperature…

2010 Neoplanta Sprint

Today is the first day of the 2010 Neoplanta Sprint , Serbia . Now I’m not really an expert in Plone , but I have had some experience with Zope 3 BlueBream , and since the sprint is taking place in my favourite city, I decided to take part. The event is taking place at Hotel Putnik , in the city centre. I’m arriving today afternoon, about 5pm. Looking forward to meet new people. View from…

Benchmarking urllib2 vs. urllib3

urllib3 seems to be a long-abandoned project on PyPI . However, it has some features (like re-using connections, aka HTTP Keep-Alive ) that are not present in the Python 2 version of urllib and urllib2 . Another package that provides HTTP Keep-Alive is httplib2 . Benchmark results on a single host Keep-Alive can significantly speed up your scraper or API client if you’re connecting to a single…

Writing your own DOM ready listener

Today I asked a question on StackOverflow on how to attach a function to the browser’s DOM ready event, in a cross-browser way, but without exporting any globals (keeping everything in an anonymous function’s closure) and without including any external file. As a result, with some help of a friendly StackOverflow user , I put together a code snippet that: takes a single function as argument,…

Asynchronous JavaScript loading

If your website has a sufficient amount of static content, it might be a good idea to load all the extra JavaScript files asynchronously. This my old blog, for example, shows the static content as soon as possible, allowing its visitors to read the main content (the article) while the not-so-important content (like Facebook Like buttons, “Web 2.0” widgets and all that crap) is on its way from the…

Berlin, Delft, and more

I’ve spent the last two weeks in Berlin , Germany , working on two projects: an ecommerce web application and a Facebook app. The former is actually an ongoing project, involving many interesting technologies, such as working with the eBay API, extending the Django admin interface, geocoding (and reverse geocoding), CMS, domain and subdomain management, etc. The other project is a small app that…

Simple Python word finder

A few days ago one of my customers asked me to put together a very simple Python script that would search through a text and find all the words that contain both letters and numbers. As simple as it may be, I’ve decided to make it a little more robust by wrapping it in a class that can be configured to split words and check patterns for each word. This is just too simple to be released as a…