Skip to content

Instantly share code, notes, and snippets.

View mbohun's full-sized avatar
🙃
How do you do?

Martin Bohun Hormann mbohun

🙃
How do you do?
  • Canberra, ACT, Australia
View GitHub Profile
@mbohun
mbohun / gist:3102307
Created July 13, 2012 02:20
Martin Bohun's SMILES tokenizer
// spidermonkey: /usr/local/spider-monkey-1.8.5/bin/js -f ./test.js
// rhino: java -jar /usr/local/rhino/js.jar -f ./test.js
//
var smiles_tokenize = function ( ) {
var PTE = [
"H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na",
"Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti",
"V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge",
"As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo",
@mbohun
mbohun / gist:3126926
Created July 17, 2012 03:48
Martin Bohun's SMILES tokenizer (re-formatted by JSLint)
var smiles_tokenize = (function () {
"use strict";
var PTE = [
"H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na",
"Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti",
"V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge",
"As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo",
"Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te",
"I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm",
"Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf",
@mbohun
mbohun / gist:3547705
Created August 31, 2012 01:55
c++0x lambda
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
vector<int> v = {0, 1, 2, 6, 6, 666};
@mbohun
mbohun / gist:3548525
Created August 31, 2012 03:14
gcc sse/sse2 fpu x387 'gcc -msse2 -mfpmath=sse'
; gcc sse/sse2 fpu x387 'gcc -msse2 -mfpmath=sse'
;
; bash-3.1$ gcc -fomit-frame-pointer -msse2 -mfpmath=sse -S test_c_asm-float-or-mmx.c
; bash-3.1$ cat test_c_asm-float-or-mmx.s
.file "test_c_asm-float-or-mmx.c"
.text
.globl test
.type test, @function
test:
subl $4, %esp
@mbohun
mbohun / gist:3548621
Created August 31, 2012 03:22
rc.local BASH notest
#!/bin/sh
#
# /etc/rc.d/rc.local: Local system initialization script.
#
# Put any local startup commands in here. Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.
#
#
@mbohun
mbohun / gist:3548717
Created August 31, 2012 03:32
sdl_surface_simple-00.c
#include <stdio.h>
#include "SDL.h"
struct {
SDL_Surface* gfx;
SDL_Rect rect;
SDL_Rect screen_pos;
int dir;
} guy;
@mbohun
mbohun / gist:3548764
Created August 31, 2012 03:36
a real rarity - a sane job interview question!
/*
http://www.suckerpunch.com
Problem Statement
The problem is to write a set of functions to manage a variable number
of byte queues, each with variable length, in a small, fixed amount of
memory. You should provide implementations of the following four
functions:
@mbohun
mbohun / gist:3548880
Created August 31, 2012 03:50
float4 type (union)
#include <stdio.h>
struct float4 {
union {
struct { float r, g, b, a; };
struct { float x, y, z, w; };
float at[4];
};
};
@mbohun
mbohun / gist:3548910
Created August 31, 2012 03:55
uint LE/BE conversion via a value called valerie :-)
#include <stdio.h>
#include <stdint.h>
int main(int argc, char* argv[]) {
union {
uint8_t bytes[4];
uint32_t valerie;
} ub_conversion;
@mbohun
mbohun / gist:3549045
Created August 31, 2012 04:24
simple jump table
#include <stdio.h>
enum {
FOO,
BAR,
LAST
};
static void foo() { printf("foo\n"); }
static void bar() { printf("bar\n"); }