Skip to content

Instantly share code, notes, and snippets.

View Xophmeister's full-sized avatar

Christopher Harrison Xophmeister

View GitHub Profile
@Xophmeister
Xophmeister / MinimalChineseWrappingDemo.opensesame
Created August 4, 2015 20:14
Minimal demonstration of wrapping problem with Chinese text
# Generated by OpenSesame 2.9.6 (Hesitant Heisenberg)
# Tue Aug 04 21:11:15 2015 (nt)
# <http://www.cogsci.nl/opensesame>
set background "black"
set bidi "no"
set canvas_backend "legacy"
set compensation "0"
set coordinates "relative"
set description "Default description"
/* MIT License
* Copyright (c) 2015 Genome Research Limited */
#include <stdio.h>
#include "khash.h"
/*
Learning how to use khash, focusing on string keys with string values
Not tried:
@Xophmeister
Xophmeister / gist:df3acce05bd024036ad1
Created May 7, 2015 21:19
Disjunction, functional style
var or = function(/* args */) {
if (arguments.length) {
var x = !!arguments[0],
xs = Array.prototype.slice.call(arguments, 1);
return x || or.apply(undefined, xs);
} else {
return false;
}
};
@Xophmeister
Xophmeister / gist:89f64fff308682e5203e
Last active August 29, 2015 14:19
Xiongxiong token authentication in Python/Flask
from datetime import datetime
from functools import wraps
from flask import Flask, request, Response
app = Flask(__name__)
# Read in the private key and instantiate xiongxiong
with open('privateKeyFile') as keyFile:
@Xophmeister
Xophmeister / gist:e745014ded101858d6c7
Last active August 29, 2015 14:01
Functional(ish) Fibonacci in C :)
#include <stdio.h>
int (*fn[2])(int);
int fib(int n) { return (*fn[n < 2])(n); }
int fibSeed(int n) { return 1; }
int fibRecur(int n) { return fib(n - 1) + fib(n - 2); }
void fibInit(void) {
fn[0] = fibRecur;
@Xophmeister
Xophmeister / authenticate.py
Last active December 31, 2015 05:39
*Really* simple Python-LDAP wrapper for query and authentication
import ldap
# *Really* simple Python-LDAP wrapper for query and authentication
# myLDAPServer = LDAP('ldap://ldap.example.com', 'o=foo')
# me = myLDAPServer.person('jbloggs')
#
# try:
# me.authenticate('abc123')
# except:
@Xophmeister
Xophmeister / gist:7369778
Last active December 27, 2015 18:29
Simple E-Mailing Wrapper around Oracle's utl_smtp
create or replace procedure email(
sender in varchar2,
recipients in varchar2,
carbon in varchar2,
subject in varchar2,
text in clob,
html in clob default null)
as
connection utl_smtp.connection;
smtpHost varchar2(30) := 'mail.example.com';
@Xophmeister
Xophmeister / gist:7138830
Created October 24, 2013 15:03
Gimmicky Names for OCaml Projects
abnormal -> abnor.ml
abysmal -> abys.ml
acetylthymol -> acetylthy.ml
actinostomal -> actinosto.ml
adiathermal -> adiather.ml
alemmal -> alem.ml
alismal -> alis.ml
Alumel -> Alu.ml
Alvissmal -> Alviss.ml
amil -> a.ml
@Xophmeister
Xophmeister / sierpinski.hs
Last active April 25, 2018 13:29
Sierpinski Triangle in Haskell
sumPairs :: [Integer] -> [Integer]
sumPairs (x:y:s) = (x + y) : sumPairs (y:s)
sumPairs _ = []
pascal :: Integer -> [Integer]
pascal 0 = [1]
pascal n = sumPairs $ [0] ++ (pascal $ n - 1) ++ [0]
sierpinski :: Integer -> String
sierpinski n = concat $ map (ascii . odd) $ pascal n
@Xophmeister
Xophmeister / gist:6461994
Created September 6, 2013 10:12
Prime numbers in Oracle :)
select level p
from dual
where not regexp_like(rpad('#', level, '#'), '^#?$|^(##+?)\1+$')
connect by level <= 1000;