Skip to content

Instantly share code, notes, and snippets.

%include "os_dependent_stuff.asm"
global fib
global _fib
fib:
_fib:
cmp rdi, 1
jle return_one; if the relationship is "less than or equal", goto return_one
push rdi ; save n
mov rsi, rdi
inc rsi ; rsi now contains n+1
@davidad
davidad / mkOpenResty
Created April 7, 2014 20:18
OpenResty configuration/build on `heroku run bash`
curl -O -L http://downloads.sourceforge.net/sourceforge/pcre/pcre-8.34.tar.gz
curl -O -L http://openresty.org/download/ngx_openresty-1.5.11.1.tar.gz
tar xzf pcre-8.34.tar.gz
tar xzf ngx_openresty-1.5.11.1.tar.gz
cd ngx_openresty-1.5.11.1
export PATH=/sbin:$PATH
./configure --prefix=/app/openresty --with-pcre=/app/pcre-8.34 --with-luajit --with-http_postgres_module --with-file-aio --with-ipv6 --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-pcre-jit --with-http_iconv_module -j2
make
make install
tar czf openresty_build-1.5.11.1-1.tar.gz openresty
@davidad
davidad / keybase.md
Created March 21, 2014 21:38
My Keybase.io public key.

Keybase proof

I hereby claim:

  • I am davidad on github.
  • I am davidad (https://keybase.io/davidad) on keybase.
  • I have a public key whose fingerprint is 7B5E C0A3 23AB 67CA E75E 9BF6 8FCE 72CF 5859 88D7

To claim this, I am signing this object:

@davidad
davidad / asmrepl.lua
Created March 1, 2014 12:08
Abusing LuaJIT as a REPL for assembly language
-- warning: this is hacky. run at your own risk.
--
-- before you run this, put sum_list.asm in a dynamic library.
--
-- on OSX that means
-- $ nasm -f macho64 sum_list.asm
-- $ libtool -dynamic sum_list.o -o libsum_list.dylib
--
-- on Linux it means
-- $ nasm -f elf64 sum_list.asm
@davidad
davidad / blog
Created February 13, 2014 19:22
#!/bin/bash
ORIGDIR=`pwd | sed 's/\ /\\ /g'`
cd ~/octopress
URL="http://davidad.github.io/"
function wrs() {
if [[ $2 = "y" ]]; then
L1="set theWindow's active tab index to theTabIndex"
@davidad
davidad / ski.c
Last active December 31, 2015 13:39
SKI combinator calculus, with the awkward addition of inert digits
// Reference implementation of combinatory algebra
#include <stdio.h>
#include <stdlib.h>
struct term {
enum {
ATOM_S,
ATOM_K,
ATOM_I,
@davidad
davidad / generate_cert.pl
Last active December 26, 2015 12:29
Some of the code I use to create client certs.
create or replace function public.generate_cert(token varchar(32), spkac text, device varchar(32)) returns text as $PERL$
my $token = $_[0];
my $spkac = $_[1];
my $device = $_[2];
use Crypt::OpenSSL::CA;
use File::Slurp;
my $rowset = spi_exec_query('select auth.certificate_tokens.cert_serial is not null as has_serial, auth.certificate_tokens.entry_id as entry_id, auth.uid_email.email as email, auth.uid_email.uid as uid, (main.people.name).given, (main.people.name).particle, (main.people.name).family, (auth.certificate_tokens.token_expires < now()) as expired from auth.uid_email, main.people, auth.certificate_tokens where auth.uid_email.uid = main.people.uid and auth.uid_email.email = auth.certificate_tokens.email and auth.certificate_tokens.token_digest = digest('.quote_literal($token).",'sha512');",1);
(define (upto n)
(letrec ((loop (lambda (k x)
(if (= k x) (list x)
(cons k (loop (+ k 1) x))) )))
(loop 1 n)))
(display (upto 10))
@davidad
davidad / gist:5551835
Created May 10, 2013 01:29
Just in case I ever need to use this somewhere
(•_•)
( •_•)>⌐■-■
(⌐■_■)
YEEEEEEEAAAAAAAAAAAHHHHH!!!!!
@davidad
davidad / gist:3956835
Last active October 12, 2015 02:27
Project Nemaload constructs

Project Nemaload constructs

Plan

Success entails a promoter and a protein combination.

Pan-neuronal promoters