Skip to content

Instantly share code, notes, and snippets.

@drewlesueur
drewlesueur / http.py
Created October 12, 2011 01:37
simplest http server
import SimpleHTTPServer,SocketServer
H = SimpleHTTPServer.SimpleHTTPRequestHandler
d = SocketServer.TCPServer(("", 80), H)
d.serve_forever()
@drewlesueur
drewlesueur / index.html
Created August 30, 2011 06:51
mood-graph
<!doctype html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<!--[if IE]><script src="excanvas.js"></script><![endif]-->
<script src="mood_chart.js"></script>
</head>
<body>
</body>
</html>
@drewlesueur
drewlesueur / gist:1122191
Created August 3, 2011 08:40
Visual basic screen shot of an application
'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319>vbc.exe /t:exe /out:.\MyOutFileName.exe inputfilename.vb
' Allow easy reference to the System namespace classes.
Imports System
' This module houses the application's entry point.
Public Module modmain
' Main is the application's entry point.
Sub Main()
' Write text to the console.
Console.WriteLine ("Hello World using Visual Basic!")
@drewlesueur
drewlesueur / module.js
Created July 29, 2011 05:11 — forked from creationix/module.js
A super simple module system for browsers. Assumes all source files are concatenated and in browser.
var defs = {};
var modules = {};
function define(name, fn) {
defs[name] = fn;
}
function require(name) {
//console.log("Loading " + name);
if (modules.hasOwnProperty(name)) return modules[name];
if (defs.hasOwnProperty(name)) {
var fn = defs[name];
@drewlesueur
drewlesueur / delete_files.sh
Created July 6, 2011 16:51
looping thru a file in bash
#Finding and removing files
for line in `cat invoices`; do find . -name "*$line*" | xargs rm -f ; done
for line in `cat invoices`; do ruby my_ruby_file $line; done
sed -i "s/<\/invoice_id>/A<\/invoice_id>/g" *
@drewlesueur
drewlesueur / test.js
Created July 1, 2011 14:05
windows script host
WScript.Echo("Hello world");
// var send = WScript.CreateObject("System.Windows.Forms.SendKeys");
// send.Send("{PRTSC}");
voice = WScript.CreateObject("SAPI.SpVoice");
voice.Speak("Hello world");
http://msdn.microsoft.com/en-us/library/d5fk67ky(v=vs.85).aspx
@drewlesueur
drewlesueur / err.py
Created June 17, 2011 16:44
Older python exception handling
def foo():
raise "error!!"
try:
foo()
except Exception, strerror:
print strerror
@drewlesueur
drewlesueur / lastingConnection.coffee
Created June 11, 2011 02:45
node mysql lasting connection
# How to make a lasting connection in node mysql
client = null
db = null
tries = 0
makeLastingConnection = =>
tries++
client = new Client
client.host = config.db.host
@drewlesueur
drewlesueur / gist:997368
Created May 29, 2011 00:53
async.js forEach vs forEachSeries
exports['forEachSeries'] = function(test){
var args = [];
async.forEachSeries([1,3,2], function(x, callback){
setTimeout(function(){
args.push(x);
callback();
}, x*25);
}, function(err){
test.same(args, [1,3,2]);
test.done();