Skip to content

Instantly share code, notes, and snippets.

##############################################
# Add git autocomple support.
source ~/.git-completion.sh
source ~/.git-prompt.sh
#
#Let's make CLI play sweetness with git.
# Git branch in prompt.
# function parse_git_dirty2 {
var merge = require('helpers/merge');
var User = function(name){this.name = name;}
var pepe = new User('pepe');
var data = {age:23, email:'[email protected]',name:'peperone'};
merge(pepe, ['age', 'email'], data);
console.log(pepe) // {name:"pepe", age:23, email:"[email protected]"}
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);

I have marked with a * those which I think are absolutely essential Items for each section are sorted by oldest to newest. Come back soon for more!

BASH

  • In bash, 'ctrl-r' searches your command history as you type
  • Input from the commandline as if it were a file by replacing 'command < file.in' with 'command <<< "some input text"'
  • '^' is a sed-like operator to replace chars from last command 'ls docs; ^docs^web^' is equal to 'ls web'. The second argument can be empty.
  • '!!:n' selects the nth argument of the last command, and '!$' the last arg
/*
original : https://gist.github.com/BinaryMuse/2378993
Changes :
-Shares an instance of phantomJS for all requests instead of creating a new one for each
-Sends the created file as a response
-Uses good old JavaScript
-Coffee version below
*/
var phantom = require('phantom'),
@goliatone
goliatone / README.md
Created July 16, 2014 18:11
Nigeria IFES

README is empty

var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 4002;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
@goliatone
goliatone / randomMac.js
Created July 26, 2014 22:40
Random mac generator
function mac(prefix) {
var mac = prefix || '54:52:00';
for (var i = 0; i < 6; i++) {
if (i % 2 === 0) mac += ':';
mac += Math.floor(Math.random() * 16).toString(16);
}
return mac;
}
Handlebars.registerHelper('chain', function() {
var helpers = [];
var args = Array.prototype.slice.call(arguments);
var argsLength = args.length;
var index;
var arg;
for (index = 0, arg = args[index];
index < argsLength;
arg = args[++index]) {
@goliatone
goliatone / random_string.js
Created August 1, 2014 15:08
One liner random string UIDish
Math.random().toString(36).substring(2);