Skip to content

Instantly share code, notes, and snippets.

View soopercorp's full-sized avatar
🚲

hardy soopercorp

🚲
View GitHub Profile
@soopercorp
soopercorp / kadane.py
Created February 19, 2012 04:57
kikin - max subarray sum
#!/usr/bin/env python
# Tested on Python 2.6
# Ref: Kadane's Algorithm
def getMaxSumSequence(arr):
maxSum = float("-inf")
start = 0
end = 0
currSum = 0
currStart = 0
@soopercorp
soopercorp / nodecamp.eu-talks-2011.md
Created June 14, 2011 10:17 — forked from a2800276/nodecamp.eu-talks-2011.md
A collection of talks and presentations held at nodecamp.eu 2011
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: First argument needs to be a number, array or string.
at new Buffer (buffer.js:156:15)
at Object.readSync (fs.js:259:14)
at Object.<anonymous> (/home/hardik/node/nowscore/test.js:3:15)
at Module._compile (module.js:407:26)
at Object..js (module.js:413:10)
at Module.load (module.js:339:31)
everyone.on('connect', function(){
//this is ok:
this.now.broadcastScore(scoreFile);
fs.watchFile(scoreFile, function () {
//how to call this one?
this.now.broadcastScore(scoreFile);
});
});
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@soopercorp
soopercorp / nodeconf_2011.md
Created May 9, 2011 09:42 — forked from mattpodwysocki/nodeconf_2011.md
a list of slides from nodeconf 2011
@soopercorp
soopercorp / gsd.sh
Created May 5, 2011 05:05 — forked from jcromartie/gsd.sh
Elegant Bash-based Get-Shit-Done script
#!/usr/bin/env bash
# edit this list, or set GSD_SITES to add your custom sites
SITES="$GSD_SITES reddit.com forums.somethingawful.com somethingawful.com digg.com break.com news.ycombinator.com infoq.com bebo.com twitter.com facebook.com blip.com youtube.com vimeo.com delicious.com flickr.com friendster.com hi5.com linkedin.com livejournal.com meetup.com myspace.com plurk.com stickam.com stumbleupon.com yelp.com slashdot.com"
HOSTFILE="/etc/hosts"
if [ ! -w $HOSTFILE ]
then
echo "cannot write to $HOSTFILE, try running with sudo"
@soopercorp
soopercorp / copyflash.sh
Created April 28, 2011 06:55
Copy downloaded Flash videos to current folder
#!/bin/bash
#
# Credit: http://www.omgubuntu.co.uk/2010/09/saving-flash-videos-in-linux-tmp-no-longer-works/#comment-145254389
# FLASHCOPY
#
# Will iterate through all open copies flashplayer and copy flash video to the
# current folder (or specified directory) with the .flv extension added.
# args=("$@")
@soopercorp
soopercorp / show
Created April 20, 2011 20:49 — forked from tekacs/show
# Usage: show <local-port> <subdomain>
function show() {
DOMAIN=".tekacs.com"
REMOTE="$2$DOMAIN"
ssh -tR 1080:127.0.0.1:$1 vps "sudo ssh -Nl \$USER -L $REMOTE:80:127.0.0.1:1080 localhost"
}