Skip to content

Instantly share code, notes, and snippets.

View alecbz's full-sized avatar

Alec Benzer alecbz

View GitHub Profile
<some-long-tag-name>
information
</some-long-tag-name>
merge :: (Ord a) => [a] -> [a] -> [a]
merge [] y = y
merge x [] = x
merge xxs@(x:xs) yys@(y:ys)
| x < y = x : merge xs yys
| otherwise = y : merge xxs ys
merge :: (Ord a) => [a] -> [a] -> [a]
merge [] y = y
merge x [] = x
merge xxs@(x:xs) yys@(y:ys)
| x < y = x : merge xs yys
| otherwise = y : merge xxs ys
$ gem
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- rubygems/gem_path_searcher (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from /home/alec/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:1087:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /home/alec/.rvm/rubies/ruby-1.9.2-p0/bin/gem:13:in `<main>'
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <plot.h>
const double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282;
const double F = 2;
double arr[16];
redis.zrevrangebyscore(@id_info_key, a, b, {:limit => [0,1]})
/*
LEAST LIKELY TO COMPILE SUCCESSFULLY:
Ian Phillipps, Cambridge Consultants Ltd., Cambridge, England
*/
#include <stdio.h>
main(t,_,a)
char
*
a;
$ ./test
./test: error while loading shared libraries: libSDL_draw-1.2.so.0: cannot open shared object file: No such file or directory
$ which libSDL_draw-1.2.so.0
/usr/local/lib/libSDL_draw-1.2.so.0
@alecbz
alecbz / levenshtein.rb
Created July 3, 2011 06:38
ruby function for Levenshtein word distance
def distance(a,b)
matrix = Array.new(a.size + 1) { Array.new(b.size + 1) }
(0..a.size).each { |i| matrix[i][0] = i }
(0..b.size).each { |j| matrix[0][j] = j }
(1..a.size).each do |i|
(1..b.size).each do |j|
if a[i-1] == b[j-1]
matrix[i][j] = matrix[i-1][j-1]
else
matrix[i][j] = [matrix[i-1][j] + 1,matrix[i][j-1] + 1,matrix[i-1][j-1] + 1].min
@alecbz
alecbz / fork.c
Created July 3, 2011 06:44
forking and piping in C
#include <stdio.h>
#include <unistd.h>
int main()
{
pid_t pid = fork();
if(pid == -1)
fprintf(stderr,"There was an error\n");
else if(pid == 0)
printf("I am the child. I do not know my pid.\n");