This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |