Skip to content

Instantly share code, notes, and snippets.

@jaseemabid
jaseemabid / supplant.js
Created October 28, 2011 04:27
JavaScript supplants
/* Supplant for templates and data filling */
if(typeof String.prototype.supplant !== 'function') {
String.prototype.supplant = function(o) {
return this.replace(/{([^{}]*)}/g,
function (a,b) {
var r = o[b];
return typeof r === 'string' ?
r : a;
});
@jaseemabid
jaseemabid / gist:1371262
Created November 16, 2011 20:26
Code to make the page as such editable.
document.body.contentEditable='true';
document.designMode='on';
@jaseemabid
jaseemabid / Curry.js
Created December 2, 2011 12:50
JavaScript Currying.
/*
* Curried code to add multiple numbers
Author : Jaseem Abid <jaseemabid@gmail.com>
* sum() expects 2 numbers are arguments
* If 2 args are provided, it returns sum as usual.
* If one arg is provided, it returns a
function which expects one more arg. JS closures can
'remember the first argument' and work accordingly.
@jaseemabid
jaseemabid / prompt.sh
Created January 25, 2012 21:20
Awesome bash prompt
# Add the following code to your ~/.bashrc for awesome bash prompt.
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
@jaseemabid
jaseemabid / producer-consumer.c
Created February 27, 2012 08:54
PRODUCER - CONSUMER Implementation in C
/** PRODUCER - CONSUMER PROBLEM **/
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <pthread.h>
#include <stdlib.h>
#define BUFSIZE 10
@jaseemabid
jaseemabid / Connect-Websocket.js
Created March 25, 2012 17:21 — forked from netroy/Connect-Websocket.js
Connect with Websockets
var connect = require('connect'),
WebSocketServer = require('websocket').server,
app = connect.createServer();
app.use(connect.static(process.cwd()));
app.use(connect.router(function(app){
app.get("/", function(req, resp) {
resp.write("Hola !");
resp.end();
@jaseemabid
jaseemabid / cookie.js
Created March 27, 2012 15:50
JavaScript Cookies
@jaseemabid
jaseemabid / xfce-panel-clock
Created June 13, 2012 13:22
XFCE panel clock
The panel clock in xfce suck! Its almost useless with is creepy color, which makes it hard to read and the stupid format with no space in between
So, it looked like old.png, customise a bit to make it look like new.png.
Use this text as the custom format to display the clock.
<span font_desc="Droid Sans Mono 10" color="#efefef" weight="normal">%a %d %b</span><span font_desc="Droid Sans Mono" color="#efefef" weight="bold"> [%I:%M %p]</span>
See the screenshots along here http://imgur.com/a/x2hma
@jaseemabid
jaseemabid / gitweb.md
Created July 31, 2012 16:58
## Status of the proposed gsoc 2012 project
@jaseemabid
jaseemabid / lang.js
Created September 16, 2012 07:38
A simple lang parser
var Translator = function () {
"use strict";
var lang,
private_map = {},
cache = [];
this.addLang = function (lang, newLangDB) {
try {
private_map[lang] = newLangDB;