A horrifying fibonacci hack

24 October 2015

It is very simple to implement programs that recursively calculate fib(n), that is the nth fibonacci number, pretty much identically to the mathematical definition of fib(n). But the problem with such programs is that they’re very slow (without DP, anyways.) O(fib(n)) slow to be specific. I realized that there would always be exactly fib(n) calls to the fib function, and this got me thinking of writing a program to calculate fib(n) by having a global counter, and then simply incrementing that counter each time fib is called.

I implemented this in C as such

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdlib.h>
#include <stdio.h>

int fib_real(int n)
{
        if (n <= 2) {
                return 1;
        } else {
                return fib_real(n-1) + fib_real(n-2);
        }
}

int count = 1;
void fib_hack(int n)
{
        if (n <= 2) {
                return;
        } else {
                count++;
                fib_hack(n-1);
                fib_hack(n-2);
        }
}

int main(int argc, char *argv[])
{
        printf("Fib real: %d\n", fib_real(atoi(argv[1])));

        fib_hack(atoi(argv[1]));
        printf("Fib hack: %d\n", count);

        return 0;
}

This program also contains the standard recursive definition of fib(n), and then shows the result of both. Of course the thing to note is that the “real” function as implemented here is just as slow as the hack.

I wonder if spammers don't use IPv6

19 August 2015

I first started using this beautiful jekyll site at the same time I got my hands on the c4k3.net domain, having previously used c4k3.org. On the new site, I decided to put my email in the footer completely unobfuscated, because I’m pretty sure it’s already on just about every spamlist out there, and I’ve gotten pretty good at ignoring spam.

One slight thing I did differently however, was to put my new @c4k3.net address instead of the old @c4k3.org. They both end up in the same inbox, but I’m slowly trying to move things over to using c4k3.net. Reading some of the more hilarious spam I’ve received, I realized I hadn’t noticed any spam sent to my @c4k3.net address, it’s all addressed to my @c4k3.org address. My @c4k3.net address has been listed unobfuscated on this google-indexed site for almost 3 months now, and apparently not a single spammer has gotten ahold of it.

Now I’m no expert on spammers, it could be that their crawlers really are that infrequent, but one explanation I like better is that having your site be IPv6-only is at the moment the number 1 defense against spam out there. To test this hypothesis, I’m going to temporarily enable IPv4 on the site, put an email in this post, and see how much (if any) spam ends up at that email.

idonthaveipv6@c4k3.org

Will post back with results.

Caps lock as super

17 August 2015 • Last edited 10 October 2015

I bought a Chromebook last year, and one of the (possibly) more notable things about its simplified keyboard is a complete lack of any caps lock key. Instead the super key is located where caps lock normally is. I quickly found this a far less awkward position for the super key, and realizing that I didn’t use caps lock anyway, I decided to remap caps lock on my other computers to the super key.

To do this, I just used the following ~/.Xmodmap

clear lock
keysym Caps_Lock = Super_L

Been running it like this for a little over 6 months now, and I couldn’t be happier.

Edit: After I’ve begun using IBus, I found it apparently doesn’t play well with Xmodmap. So I switched over to using XKb, which does work well with IBus. My new configuration (in my xorg.conf.d) is now:

Section "InputClass"
	Identifier "keyboard defaults"
	MatchIsKeyboard "on"

	Option "XKbOptions" "caps:super"
EndSection