Skip to content

Instantly share code, notes, and snippets.

Alberto Zaccagni lazywithclass

Block or report user

Report or block lazywithclass

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
lazywithclass / c for copy
Created Jul 24, 2011
Append c to a command and see its output copyed in the clipboard (xclip needed)
View c for copy
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
lazywithclass / partial
Created Aug 22, 2011
Partial function application
View partial
function partial(func /*, 0..n args */) {
var args =, 1);
return function() {
var allArguments = args.concat(;
return func.apply(this, allArguments);
lazywithclass /
Created Oct 19, 2011 — forked from jasonrudolph/
Programming Achievements: How to Level Up as a Developer
lazywithclass / gist:1372959
Created Nov 17, 2011
Version control aware ps1
View gist:1372959
. /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 && (
lazywithclass / gist:1378190
Created Nov 19, 2011
Invert a string (the inefficient way)
View gist:1378190
public static String invert(String invertMe) {
StringBuilder output = new StringBuilder();
for (int i=invertMe.length(); i>0; i--) {
return output.toString();
View gist:1388891
lazywithclass / gist:1402417
Created Nov 28, 2011
Fibonacci tail recursion in Scheme
View gist:1402417
(define (fib n)
(define (iter a b count)
(if (<= count 0)
(iter b (+ a b) (- count 1))))
(iter 0 1 n))
lazywithclass / gist:1402456
Created Nov 28, 2011
Fibonacci tail recursion in Java
View gist:1402456
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;
View gist:1411161
public class Test {
class Parent {}
class Child extends Parent {}
public void accept(Parent[] parent) {
public static void main(String[] args) {
lazywithclass / gist:1506587
Created Dec 21, 2011
Quick each (took from here without spaces)
View gist:1506587
// 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(){
You can’t perform that action at this time.