- Project : Use JavaScript library / framework in gitweb
- Project Description : https://github.com/peff/git/wiki/SoC-2012-Ideas
- Code : https://github.com/jaseemabid/git/commits/gitweb
- DONE Port all existing functionality except ajaxy blame.
/* 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; | |
}); |
document.body.contentEditable='true'; | |
document.designMode='on'; |
/* | |
* 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. |
# 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)]/" | |
} |
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(); |
var Translator = function () { | |
"use strict"; | |
var lang, | |
private_map = {}, | |
cache = []; | |
this.addLang = function (lang, newLangDB) { | |
try { | |
private_map[lang] = newLangDB; |
// Shift multiplication | |
var shiftProduct = function (a, b) { | |
"use strict"; | |
var product = 0, | |
a_ = a, | |
b_ = b, | |
bPower = 0, // Max power of b to shift | |
bNeg = (b < 0) ? true : false; |
_ = require('underscore') | |
log = console.log | |
getDistinctSortedSubsequences = (word) -> | |
# Sort the string | |
sorted = word.split("").sort().join("") | |
# Computes powerset of string | |
# Ref : http://rosettacode.org/wiki/Power_set#JavaScript |