This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
command_not_found_handle() { | |
if [ $(echo $1 | cut -d' ' -f1 | grep ".*c$") ]; then | |
echo "copying $(echo $1 | sed 's/^\([a-z][a-z]*\)c.*/\1/') results in your clipboard..." | |
exec $(echo $1 | sed 's/^\([a-z][a-z]*\)c.*/\1/') | copy | |
#just pasted the body of the system-wide function to handle c-n-f | |
#if the command-not-found package is installed, use it | |
elif [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found ]; then | |
# check because c-n-f could've been removed in the meantime | |
if [ -x /usr/lib/command-not-found ]; then | |
/usr/bin/python /usr/lib/command-not-found -- $1 |
function partial(func /*, 0..n args */) { | |
var args = Array.prototype.slice.call(arguments, 1); | |
return function() { | |
var allArguments = args.concat(Array.prototype.slice.call(arguments)); | |
return func.apply(this, allArguments); | |
}; | |
} |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
. /etc/bash_completion.d/git | |
function customW { | |
echo $PWD | sed 's|.*/\([a-Z0-9][a-Z0-9]*/[a-Z0-9][a-Z0-9]*\)|\1|' | |
} | |
function hasToPush { | |
git diff-index --quiet --cached HEAD &>/dev/null && | |
(git svn dcommit --dry-run 2>/dev/null | grep -q "diff-tree" && echo "↑") | |
} | |
function hasToPull { | |
git diff-index --quiet --cached HEAD &>/dev/null && ( |
public static String invert(String invertMe) { | |
StringBuilder output = new StringBuilder(); | |
for (int i=invertMe.length(); i>0; i--) { | |
output.append(invertMe.charAt(i-1)); | |
} | |
return output.toString(); | |
} |
[SeatDefaults] | |
greeter-session=lightdm-gtk-greeter | |
user-session=xubuntu |
(define (fib n) | |
(define (iter a b count) | |
(if (<= count 0) | |
a | |
(iter b (+ a b) (- count 1)))) | |
(iter 0 1 n)) |
public static long tailRecursive(long n) { | |
if (n <= 2) { | |
return 1; | |
} | |
return tailRecursiveAux(0, 1, n); | |
} | |
private static long tailRecursiveAux(long a, long b, long count) { | |
if(count <= 0) { | |
return a; |
public class Test { | |
class Parent {} | |
class Child extends Parent {} | |
public void accept(Parent[] parent) { | |
System.out.println("accepted"); | |
} | |
public static void main(String[] args) { |
// The `quickEach` method will pass a non-unique jQuery instance | |
// to the callback meaning that there will be no need to instantiate | |
// a fresh jQuery instance on each iteration. Most of the slow-down | |
// inherent in jQuery's native iterator method (`each`) is the constant | |
// need to have access to jQuery's methods, and so most developers | |
// see constructing multiple instances as no issue... E.g. | |
// $(...).each(function(){ $(this)... $(this)... $(this)... }); | |
// A better approach would be `quickEach`. | |
jQuery.fn.quickEach = (function(){ |