Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name Diff for gist.github
// @description adds a diff function to http://gist.github.com/
// @namespace http://userscripts.org/users/40991
// @include http://gist.github.com/*
// @include https://gist.github.com/*
// ==/UserScript==
// Working for Safari/Webkit with GreaseKit
// A few minor tweaks. I also inlined the requires,
int str_cmp( char *str1, char *str2 ) {
if ( !*str1 && !*str2 )
return 0;
char a = *str1, b = *str2;
if( a >= 'a' && a <= 'z' )
a -= 32;
if( b >= 'a' && b <= 'z' )
b -= 32;
void str_remove_char ( char array[], int c ) {
int i, j;
for ( i = j = 0; array[i]; ++i ) {
if ( array[i] != c )
array[j++] = array[i];
}
array[j] = '\0';
}
function make_adder( left_operand ) {
return function ( right_operand ) {
return left_operand + right_operand;
};
}
// so, you can say:
var plus_two = make_adder(2);
var plus_three = make_adder(3);
alert(plus_two(5)); //=> 7