Skip to content

Instantly share code, notes, and snippets.

@naholyr
naholyr / gist:1048660
Created June 27, 2011 10:45
Quick 'n dirty Bash completion for "pman"
We couldn’t find that file to show.
@naholyr
naholyr / 01-db-test.js
Created August 27, 2011 09:39
REST avec NodeJS & Express - Tests Unitaires
var assert = require('assert')
, db = require('../db')({namespace:'bookmarks-test-db'})
, the_bookmark = {}
require('vows')
.describe('bookmarks-db')
.addBatch({
"Initialize": {
topic: function () {
db.deleteAll(this.callback);
@naholyr
naholyr / app.js
Created August 27, 2011 10:13
REST avec NodeJS & Express - Application
var express = require('express')
, app = module.exports = express.createServer()
app.configure(function () {
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
app.configure('development', function () {
@naholyr
naholyr / update-sublime-text.sh
Created September 6, 2011 15:27
Install or update Sublime Text from web site
#!/bin/bash
# Requirements: sed, grep, curl, pkill
# User configuration
LOCAL_INSTALL="/usr/lib/sublime-text-2" # Must be user-writable
REPO="dev" # "dev" for dev releases, or "2" for beta releases
TARGET_BUILD="Linux 32 bit" # can be one of "Windows", "Windows 64 bit", "OS X", "Linux 32 bit", "Linux 64 bit"
# Check if sublime text is running
@naholyr
naholyr / binlog-tailer.js
Created October 11, 2011 21:29 — forked from laverdet/binlog-tailer.js
MySQL binlog tailer
"use strict";
this.MysqlBinlogTailer = MysqlBinlogTailer;
var EventEmitter = require('events').EventEmitter;
var fs = require('fs');
var path = require('path');
/**
* Tails a Mysql binlog and emits an event for every query executed.
*/
@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
@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 / decode_live.free.fr.sh
Created January 5, 2012 09:55
Decode MD5 from live.free.fr
#!/bin/bash
# <troll>If you don't have bash, go get a real OS.</troll>
curl -s "http://md5.noisette.ch/md5.php?hash=$(curl -s http://live.free.fr | gunzip | tail -n 36 | head -n 32 | grep '[a-f0-9]' -o | xargs echo -n | sed 's/ //g')" | grep '<string>' | sed 's/^.*\[CDATA\[\(.*\)\]\].*$/\1/'
@naholyr
naholyr / command.sh
Created January 5, 2012 23:10
Failed continuous replication with CouchDB
curl -H 'Content-Type: application/json' -X POST http://localhost:5984/_replicate -d ' {"source": "http://isaacs.iriscouch.com/registry", "target": "npmregistry", "create_target": true, "continuous": true} '
@naholyr
naholyr / auth.js
Created January 10, 2012 06:22
[snippet] implement "remember me" with BrowserId
// https://github.com/mozilla/browserid/wiki/Advanced-BrowserID-Features
function login () {
function gotAssertion (assertion) {
if (assertion) {
// User chose not to log in, or an error occurred
} else {
// Ajax call to server to check email
}
}