Skip to content

Instantly share code, notes, and snippets.

View rampion's full-sized avatar

Noah Luck Easterly rampion

  • Mercury Technologies
View GitHub Profile
@rampion
rampion / gist:72614
Created March 2, 2009 04:55
example of bugs with natural join in oracle
-- on Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
CREATE TABLE left(lid INTEGER, pid INTEGER);
INSERT INTO left VALUES (1,1);
INSERT INTO left VALUES (2,2);
INSERT INTO left VALUES (3,3);
INSERT INTO left VALUES (4,4);
INSERT INTO left VALUES (5,5);
CREATE TABLE right(rid INTEGER, pid INTEGER);
INSERT INTO right VALUES (1,1);
#!/usr/bin/env ruby
# solver for http://numb3rs.wolfram.com/516/puzzle.html
# a node in the graph
Node = Struct.new(:label, :color, :edges)
class Node
# hash equalit for nodes is only dependent on label (which is unique)
def hash
label.hash
end
@rampion
rampion / try-catch-ex.c
Created April 8, 2009 02:35
TRY/CATCH/FINALLY macros for C
// gcc -o try-catch-ex try-catch.c try-catch-ex.c
#include <stdio.h>
#include "try-catch.h"
// Example of use for try-catch.h
int main(int argc, char *argv[])
{
int i = 101;
printf("before try block...\n");
@rampion
rampion / makeup.sh
Created April 9, 2009 12:46
zsh function to recursively ascend the path tree until we hit root or find a makefile, then make
# zsh function to recursively ascend the path tree until we hit root or find a makefile, then make
function makeup()
{
if ([[ $PWD == "/" ]] || [[ -f Makefile ]] || [[ -f makefile ]] ) ; then
make $*
else
(pushd .. >/dev/null ; makeup $*)
fi
}
@rampion
rampion / yet-another-rot13.vim
Created April 19, 2009 21:24
how may ways can you say ROT13
:%s/.*/\=tr(submatch(0),'abcdefghijklmnopqrstuvwxyz','nopqrstuvwxyzabcdefghijklm')
@rampion
rampion / refactor.vim
Created April 19, 2009 22:05
vim script for refactoring using a dictionary
" Refactor the given lines using a dictionary
" replacing all occurences of each key in the dictionary with its value
function! Refactor(dict) range
execute a:firstline . ',' . a:lastline . 's/\C\<\%(' . join(keys(a:dict),'\|'). '\)\>/\='.string(a:dict).'[submatch(0)]/ge'
endfunction
command! -range -nargs=1 Refactor :<line1>,<line2>call Refactor(<args>)
" Example of use
" :%Refactor {'duck':'frog', 'frog':'rabbit', 'rabbit':'duck', 'I':'Noah'}
@rampion
rampion / backup.crontab
Created April 29, 2009 20:01
better vim backup strategy
# clean up any backups not used in the past 7 days out of the ~/.backup directory
@daily find ~/.backup -type f -name '*;*' -not \( -atime 0 -or -atime 1 -or -atime 2 -or -atime 3 -or -atime 4 -or -atime 5 -or -atime 6 \) -delete
@rampion
rampion / nextunused.vim
Created May 2, 2009 03:21
vim plugin for using numbered temp files
" ~/.vim/plugin/nextunused.vim
" find the next unused filename that matches the given pattern
" counting up from 0. The pattern is used by printf(),
" so use 'temp%d.txt' for 'temp0.txt' to 'temp99999.txt' and
" 'temp%04d.txt' for 'temp0000.txt' to 'temp9999.txt'.
function! GetNextUnused( pattern )
let i = 0
while filereadable(printf(a:pattern,i))
let i += 1
@rampion
rampion / clearonclick.user.js
Created May 11, 2009 15:51
remove default onclick behaviour from links
// ==UserScript==
// @name clearonclick
// @namespace http://rampion.myopenid.com
// @description clear onclick behaviour from html links
// @include http://andrewsullivan.theatlantic.com/the_daily_dish/*
// ==/UserScript==
try {
GM_log("called");
const links = document.getElementsByTagName('a');
@rampion
rampion / test data.txt
Created May 14, 2009 20:56
Some random names and addresses I generated for test data
+--------------------------------+--------------------------------------------------------------------+
| name | address |
+--------------------------------+--------------------------------------------------------------------+
| Evagation Governessy | 803 Asbestous St, Uneradicated Stannous MP 37441 |
| Civilizee Fangle | 997 Cerebrotonic Hwy, Ulex Lynceus ZQ 07893 |
| Terebenic Parandrus | 687 Veneralia Way, Frivoler Myospasm NC 14839 |
| Loaminess Pezizaceous | 859 Dustcloth Way, Drivepipe Miolithic XV 26760 |
| Dominican Ozostomia | 73 Dichasial Way, Moniker Utilizable RS 84766 |
| Autobiology Impishly | 602 Dynamize Way, Lernaeidae Macrochemical CB 42656 |
| Exopodite Unendamaged | 139 Osteolysis Hwy, Synergist Leally TO 05002