Skip to content

Instantly share code, notes, and snippets.

@drewlesueur
drewlesueur / lcs.coffee
Created November 23, 2010 08:38
Algorightms homework :(
lcs_length = (x,y) -> #1 indexed arrays
m = x.length - 1
n = y.length - 1
c = []
b = []
for i in [0..m]
c[i] = []
b[i] = []
c[i][0] = 0
for j in [1..n]
@drewlesueur
drewlesueur / mcm.coffee
Created November 23, 2010 05:12
Algorithms homework :(
mcm = (p) ->
console.log "test"
m = []
s = []
n = p.length - 1
$(document.body).css "height", "20000px"
table = ["<table id='mcm' cellpadding=0 cellspacing=0 style='border-collapse: collapse; -webkit-transform: rotate(135deg) translate(-100px, -300px); '>"]
for a in [1..n]
table.push "<tr colspan='a'>"
for b in [1..a]
@drewlesueur
drewlesueur / estimate.coffee
Created November 19, 2010 23:14
hours estimator helper
a = t()
low = 0
high = 0
a.replace /^[\d]+\-[\d]+ hours/mig , (hours) ->
#console.log hours
hours = hours.split " "
hours = hours[0]
hours = hours.split "-"
low += hours[0] - 0
high += hours[1] - 0
<img src="pics/IMG_1255.jpg" width="300"><br>
<img src="pics/IMG_1256.jpg" width="300"><br>
<img src="pics/IMG_1257.jpg" width="300"><br>
<img src="pics/IMG_1258.jpg" width="300"><br>
<img src="pics/IMG_1259.jpg" width="300"><br>
@drewlesueur
drewlesueur / image_functions.php
Created November 17, 2010 03:42
Simple image manipulation functions for php
public static function resize_image($image, $w, $h) {
$ret = imagecreatetruecolor($w, $h);
imagealphablending( $ret, false );
imagesavealpha( $ret, true );
imagecopyresampled($ret, $image, 0, 0, 0, 0, $w, $h, imagesx($image), imagesy($image));
//imageantialias($ret,true);
return $ret;
}
public static function overlay_image($image, $overlay, $x, $y) {
@drewlesueur
drewlesueur / csv_to_array.php
Created November 17, 2010 03:42
Simple Csv parser for PHP <= 5.2
public static function csv_to_array($csv) {
if (substr($csv,-1) != "\n" && substr($csv,-1) != "\r") {
$csv .= "\n";
}
$len = strlen($csv);
$table = array();
$cur_row = array();
$cur_val = "";
$state = "first item";
@drewlesueur
drewlesueur / closure.coffee
Created November 9, 2010 00:46
Example of a closure in CoffeeScript
person = () ->
name = "Fred"
ret =
getName: () ->
return name
setName: (newName) ->
name = newName
bob = person()
alert bob.getName()
@drewlesueur
drewlesueur / sites-enabled-file2
Created November 8, 2010 19:46
Hook up node.js with apache.
#hook up node.js with apache so you can have an apache site on port 80
# and a node.js server running on port 80
# you may need to `a2enmod proxy` and `a2enmod proxy_http`
<VirtualHost *:80>
ServerName severus.the.tl
ProxyPass / http://127.0.0.1:86/
# CustomLog /var/log/apache2/lazeroids-node-access.log combined
# ErrorLog /var/log/apache2/lazeroids-node-error.log
# NoCache *
<Proxy *>
@drewlesueur
drewlesueur / sites-enabled-file
Created November 8, 2010 19:44
infinite subdomains
#allows you to have infinite subdomains
<VirtualHost *:80>
# first do a2enmod vhost_alias
ServerName anything.the.tl
ServerAlias *.the.tl
UseCanonicalName Off
VirtualDocumentRoot /root/workspace/sites/%0 # %0 is the full domain name
</VirtualHost>
@drewlesueur
drewlesueur / .vimrc
Created November 8, 2010 08:15
My vimrc
call pathogen#runtime_append_all_bundles()
filetype plugin indent on
set backspace=indent,eol,start
set tabstop=2
set shiftwidth=2
set expandtab
"colorscheme jellybeans
ino jj <esc>
cno jj <c-c>
vno v <esc>