Skip to content

Instantly share code, notes, and snippets.

This is uncached. It has O(2^n) time complexity.

def fib(n):
    return n if n < 2 else fib(n-1) + fib(n-2)

We can pretty easily make this O(n) by introducing a caching decorator.

@astex
astex / test_client.c
Created February 7, 2016 00:28
Test client for gfclient.c/gfserver.c
#include <stdio.h> // fprintf, stdout
#include <stdlib.h> // malloc
#include <getopt.h> // getopt_long, option, required_argument
#include <string.h> // strcmp
#include "gfclient.h"
#define USAGE \
"usage:\n" \
" webclient [options]\n" \
@astex
astex / methodize.py
Created May 5, 2014 16:19
Python methodize decorator
from functools import wraps
def methodize(dec):
"""Decorates a function decorator so it can wrap methods.
Usage:
```
@methodize(decorator)
function(self, *args, **kargs):
#...
@astex
astex / bumblebee-amd-git bug
Created December 29, 2013 20:34
Output when attempting to run optirun and the involved card information.
$ optirun --debug glxgears
[ 682.669476] [DEBUG]optirun version 3.0-51-ga00f533 starting...
[ 682.669494] [DEBUG]Active configuration:
[ 682.669497] [DEBUG] bumblebeed config file: /etc/bumblebee/bumblebee.conf
[ 682.669500] [DEBUG] X display: :8
[ 682.669503] [DEBUG] LD_LIBRARY_PATH:
[ 682.669505] [DEBUG] Socket path: /var/run/bumblebee.socket
[ 682.669507] [DEBUG] VGL Compression: proxy
[ 682.686906] [INFO]Response: No - error: [XORG] (EE) RADEON(0): [drm] failed to set drm interface version.