Skip to content

Instantly share code, notes, and snippets.

View esamattis's full-sized avatar

Esa-Matti Suuronen esamattis

View GitHub Profile
@remy
remy / gist:350433
Created March 31, 2010 14:58
Storage polyfill
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
@creationix
creationix / streamtest.js
Created January 1, 2011 08:57
A sample client for creationix/jsonparse that consumes the twitter feed and filters out messages and names
var Parser = require('./jsonparse');
var Http = require('http');
var p = new Parser();
// IMPORTANT, put your username and password in here
var username = "yourTwitterUsername", password = "yourPassword";
var client = Http.createClient(80, "stream.twitter.com");
var request = client.request("GET", "/1/statuses/sample.json", {
"Host": "stream.twitter.com",
"Authorization": (new Buffer(username + ":" + password)).toString("base64")
});
@thelinuxlich
thelinuxlich / coffee_watcher
Created February 8, 2011 18:55
This shellscript watches coffee files for changes and compiles them and runs docco after
#!/bin/sh
# use my inotify-tools fork at https://github.com/thelinuxlich/inotify-tools
# use my docco fork if you want to generate php documentation(npm install thelinuxlich-docco)
while output=`inotifywait -r -e create -e close_write -e modify --format '%w %f' --include ".*\.(coffee|php)$" /srv/www/htdocs/php/`; do
DIR=${output%% *}
DOCDIR=${DIR/php\//php\/docs/}
FILE=${output#* }
echo "Detected a change in ${DIR}${FILE} ..." >> /srv/www/htdocs/php/logs/watcher.log
if [[ $FILE == *.coffee* ]]
then
@coolaj86
coolaj86 / fs.extra.js
Last active May 22, 2022 22:45
fs.copy and fs.move for Node.JS
/*
UPDATE: this has finally been pushed to npm as `fs.extra`
URL: https://github.com/coolaj86/utile-fs/tree/master/fs.extra
*/
(function () {
"use strict";
console.warn('[Deprecated] See https://github.com/coolaj86/utile-fs');
var fs = require('fs')
@esamattis
esamattis / .pdbrc
Created August 4, 2011 12:18
What every python developer should have in their ~/.pdbrc
# Enable tab completion
import rlcompleter
import pdb
pdb.Pdb.complete = rlcompleter.Completer(locals()).complete
# Sometimes when you do something funky, you may lose your terminal echo. This
# should restore it when spanwning new pdb.
import termios, sys
termios_fd = sys.stdin.fileno()
termios_echo = termios.tcgetattr(termios_fd)
@terotil
terotil / gol.rb
Created August 17, 2011 23:35
Conway's Game of Life
#!/usr/bin/ruby
seed = <<eos
..........
..........
..#.......
...#......
...##.....
...##.....
....#.....
@balupton
balupton / README.md
Last active September 29, 2018 18:31
Responsive layouts in stylus

Responsive layouts in stylus

Why this way?

  1. There is no span1..15 styles, instead your css defines your layout and your html remains semantic and not polluted with display information. As it should be.

  2. The markup is incredibly easy, you specify the wrappers width, and then each columns width in percentages. Every other grid framework I've found is incredibly complicated with this.

  3. It allows you to have the exact same markup, and completely different styles for different devices, resolutions, stylesheets, whatever. As it should be.

@JeffreyWay
JeffreyWay / gist:1608901
Created January 13, 2012 21:53
Inline Web Workers
<!doctype html>
<html>
<head>
<title>Web Workers</title>
</head>
<body>
<script id="worker" type="app/worker">
addEventListener('message', function() {
postMessage('What up, sucka.');
@JerrySievert
JerrySievert / gist:3119325
Created July 16, 2012 00:08
Working Node.js on Raspberry Pi
These instructions should be deprecated at this point.
Start following https://github.com/TooTallNate/node/tree/pi for a more straightforward node installation on the pi.
----
These instructions work for the Raspberry Pi running Raspbian (hard float), and include a working NPM:
1. Install Raspbian - http://www.raspbian.org/PiscesImages