Skip to content

Instantly share code, notes, and snippets.

@isaacs
isaacs / .gitconfig
Created June 8, 2012 19:01
These are my shortcuts for git.
# A bunch of the stuff above relies on this, especially the aliases.
[user]
# you probably want to change this bit.
name = isaacs
email = i@izs.me
signingkey = 0x6C481CF6
[alias]
ci = commit
st = status
br = branch
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
@naholyr
naholyr / .bashrc.sh
Created March 23, 2012 11:44
Git bisect for SVN
function svn-bisect() {
local TEST="$1"
local TARGET="${2:-.}"
local LEFT=${3:-1}
local RIGHT=${4:-$(LANG=LC svn info | grep ^Revision | sed 's/Revision: //')}
if ! echo "$LEFT" | grep '^[0-9]\+$' > /dev/null; then
echo 'Starting revision must be a valid number' >&2
exit 1
fi
Stability ratings: 0-5
0 - Deprecated. This feature is known to be problematic, and changes are
planned. Do not rely on it. Use of the feature may cause warnings. Backwards
compatibility should not be expected.
1 - Experimental. This feature was introduced recently, and may change
or be removed in future versions. Please try it out and provide feedback.
If it addresses a use-case that is important to you, tell the node core team.
@naholyr
naholyr / examples-and-issues.js
Created January 22, 2012 18:08
Writing a "url_for" helper for Express
// What name can I refer to ?
app.get('/hello-world', function () { console.log(3); });
// OK, suppose I can build the path from params
app.get('/:id/:name', function hello1 () { console.log(1); });
// OK, suppose the "callback" is the last one
app.get('/hello/:name', requiresAuthentication, function hello2 () { console.log(2); });
// How do I build the path ?
@indexzero
indexzero / include.js
Created January 22, 2012 09:03
Find the source of your `sys` deprecation warnings in node@0.6.x
//
// Place this at the beginning of your node.js program before
// **any and all** require statements.
//
var util = require('util');
var _warning = util._deprecationWarning;
util._deprecationWarning = function () {
console.trace();
_warning.apply(util, arguments);
@n1k0
n1k0 / meta-extract.js
Created January 21, 2012 07:02
CasperJS script to extract meta informations
var casper = require("casper").create()
, url = casper.cli.get(0)
, metas = [];
if (!url) {
casper.echo('Usage: casperjs [url]').exit();
}
casper.on('remote.message', function(msg) {
console.log(msg);
@marcw
marcw / sopa.vcl
Created January 17, 2012 20:43
Varnish vcl file in order for varnish to participate to the sopa blackout
# use with:
#
# varnishadm -T host:port -S /etc/varnish/secret "vcl.load sopa /path/to/your/sopa.vcl"
# varnishadm -T host:port -S /etc/varnish/secret "vcl.use sopa"
backend default {
.host = "127.0.0.1";
.port = "8080";
}
@naholyr
naholyr / block-social-networks.sh
Created December 21, 2011 15:09
Bash Pomodoro using libnotify
#!/bin/bash
# Destination: ~/.pomodoro/hooks/work.d/
# Goal: block access to Twitter and Facebook while in a Pomodoro
# Note: won't work if you use Chrome, as it maintains an internal (not flushable from CLI) DNS cache. Fuck it.
# This file must be able to touch "/etc/hosts":
# The best way would be to create a group able to modify the "/etc/hosts" file:
# $ sudo addgroup host-manager
# $ sudo chgrp host-manager /etc/hosts
@naholyr
naholyr / bash_aliases.sh
Created November 24, 2011 10:13
Smart svn annotate for bash
# Usage: svn-annotate file [start-line [end-line]]
# Will output svn annotate on file + line numbers
# eventually cut depending on the given lines
function svn-annotate() {
# Work on a tempfile to avoid broken pipe
f=$(tempfile)
svn annotate "$1" > $f
CAT="cat -n" # Integrate line numbers, just remove the "-n" to disable
if [ "$2" == "" ]; then
# No start or end line