Welcome to the first post on my blog! nanoc3 is a framework to compile static websites; as only i am modifying the content, there is no need for any dynamic part in it - i can just update the static files when i want to change something. A static website has some interesting features: No need for any database setup No need to run php/python/ruby/perl (or whatever you would use to generate pages)…
DomainKeys Identified Mail (DKIM) is used to prevent people from sending spam mails with “from” mail addresses from your domain; you announce with DNS records that you sign all your mails with a RSA key, and everyone can check whether mails have been really sent by you. For this it hashes (parts of) the body and some headers, and signs these hashes with the private RSA key; the public…
Each time i have to code in Ada i just hate the language… it makes “clean” coding a pain in the ass (easy workarounds would include using pointers everywhere). This time i need to use protected objects; protected objects have some associated code blocks (entries, procedures and functions), which can access the private data part; but only one thread can enter such block for one…
I already mentioned that i don’t like Ada, but I didn’t expect to hit something like this: $ gnatmake gnatbug gcc-4.4 -c gnatbug.adb +===========================GNAT BUG DETECTED==============================+ | 4.4.6 (x86_64-pc-linux-gnu) Assert_Failure sem_ch3.adb:1063 | | Error detected at gnatbug.adb:3:17 | | Please submit a bug report; see http://gcc.gnu.org/bugs.html. | | Use a…
I wanted to export all wiki pages of a redmine project as plain text (the original textile code) with a small yaml header: ~/redmine $ RAILS_ENV=production ./script/console -s Loading production environment in sandbox (Rails 2.3.11) Any modifications you make will be rolled back on exit NOTE: SourceIndex.new(hash) is deprecated; From…
A glibc change committed one year ago ( Improve 64bit memcpy/memmove for Atom, Core 2 and Core i7 ), which already resulted in some flamewars discussions (involving Linus Torvalds vs. Ulrich Drepper ), broke some applications which used memcpy when they should have used memmove (only the latter handles overlapping memory areas). Many applications have probably been fixed, but Adobe never took…
Why you want packages instead of building software yourself ¶ Open source projects often have more or less simple instructions to build their software. Sometimes this can be the right thing to use, but often you want a better integration into your system; for example init scripts, logrotate configs, config files, … Using packages also provides an easy way to get rid of the software…
Many people know a very basic fact about Fibonacci numbers : \[ gcd(F_n, F_{n+1}) = 1 \] In other words: \(F_n\) and \(F_{n+1}\) are coprime There is a more generic form: \[ gcd(F_n, F_m) = F_{gcd(n, m)} \] The first proposition follows from this, as \(gcd(n, n+1) = 1\) . Some time ago Johannes and I discovered another fact if n is coprime to 2 and 3: \[ n \bmod{6} \in \{ 1, 5 \} \Rightarrow…
I just had a very stupid bug in a lighttpd2 feature I was working on, it looked like this: ```c linenums=1 typedef enum { S_DEAD, S_START / … / } con_state; typedef struct { con_state state; / … / } con; void foo(con c) { if (S_DEAD == c) { / … */ } } I obviously wanted to check `c->state`, not `c` - and I didn't even get a warning from my compiler (neither gcc nor clang).…
It’s not a bug, it’s a feature! Often you want to execute specific code when a object is destroyed - for example free all pointers in it. In Ada you need the Ada.Finalization package for this, which provides you with the Controlled and the Limited_Controlled tagged types; they allow custom action for Initialize , Adjust (not for limited) and Finalize . Example: ```ada linenums=1…
There is a nice repository on build.opensuse.org which provides some useful packages to cross compile from linux, and I’m going to describe a simple setup using cmake and Qt: First install openSUSE 12.1 into a virtual machine (unless you want to do it on a real machine). Then add the extra repositories and install the needed packages (as root): zypper ar…
Verify whether a certificate matches a private key and has valid timestamp ¶ The certificate is the signed public key (and some meta data); to verify whether a certificate matches the private key, one has to extract the public key of both and compare them. Both the rsa and the x509 subcommand of openssl have a -modulus option to extract the modulus; they can also extract the complete public…
SSH only takes a simple string as command to send to the remote end 1 . In other words, ssh has to concatenate all arguments with a space as separator. Example: $ ssh stbuehler.de echo Hello World Hello World In this case, my local ssh program gets the command ['echo', 'Hello', 'World'] from the system, build the command string 'echo Hello World' from, sends it to my server, and the ssh process…
What is SHA-3? ¶ SHA-3 is a family of cryptographic hash functions (also see SHA-3 on Wikipedia ). NIST selected Keccak as implementation for SHA-3 in October 2012, and released a draft specifying the details in April 2014. I think the algorithm details are final. How does it work? ¶ Keccak consists of two components: Permutation functions Keccak-f for specific state sizes (1600, 800,…
TLDR: don’t use unions for type punning; always use memcpy . Sometimes you might want to reinterpret a value of one type as value of another type. For example you might have an integer parameter, but you know that it actually contains a float value. Let’s assume the integer was large enough to store the float somehow, and now you want to get the value back. If you follow wikipedia you…
Sometimes services are started by systemd with already dropped privileges, for example inspircd.service starts as irc user. Such services cannot bind to priliged ports ( < 1024 ) usually - in this case I needed it to listen to port 443 though (additionally to some high port) to allow users behind special firewall configurations to connect to the server. The solution is to add the following to the…
There are various reasons why one would prefer 64-bit over 32-bit (or not); basically it is about improved ABI (passing arguments in registers), bigger register (can be faster) versus higher memory usage (because pointers are twice as big). In some corner cases you want 64-bit to be able to use more memory in your programs (32-bit kernels can often handle more than 4G memory, but 32-bit userspace…
It isn’t uncommon on linux systems to have muliple (layer 3, i.e. with IP addresses, not counting the loopback device) network interfaces. For example your main interface (with the default route) and a docker bridge. Or you run a firewall between a public network and one or many internal networks (perhaps as tagged VLAN interfaces). But in rather rare scenarios you need multiple default…