Skip to content

Instantly share code, notes, and snippets.

View Zorono's full-sized avatar
😌
I may be slow to respond.

John Magdy Lotfy Kamel Zorono

😌
I may be slow to respond.
View GitHub Profile
@iangreenleaf
iangreenleaf / rsync-retry.sh
Created January 18, 2010 07:12
rsync with retries
#!/bin/bash
### ABOUT
### Runs rsync, retrying on errors up to a maximum number of tries.
### Simply edit the rsync line in the script to whatever parameters you need.
# Trap interrupts and exit instead of continuing the loop
trap "echo Exited!; exit;" SIGINT SIGTERM
MAX_RETRIES=50
@defunkt
defunkt / browser
Created March 1, 2010 10:01
pipe html to a browser
#!/bin/sh -e
#
# Usage: browser
# pipe html to a browser
# e.g.
# $ echo '<h1>hi mom!</h1>' | browser
# $ ron -5 man/rip.5.ron | browser
if [ -t 0 ]; then
if [ -n "$1" ]; then
@voyeg3r
voyeg3r / apt-fast
Created May 21, 2010 16:18
apt-fast with aria2c
#!/bin/sh
# Last Change: 2011/10/06
# apt-fast v0.02 by Matt Parnell http://www.mattparnell.com, this thing is fully open-source
# if you do anything cool with it, let me know so I can publish or host it for you
# contact me at admin@mattparnell.com
# Special thanks to Travis/travisn000 from the PCLinux Forums for making improvements that allow
# for more complex apt-get commands. See the thread: http://www.pclinuxos.com/forum/index.php/topic,66385.0.html
# adicionar suporte aos metalinks no aria2: http://ubuntuforums.org/showthread.php?t=1493421
# veja também apt-metalink: http://github.com/tatsuhiro-t/apt-metalink
#!/usr/bin/python
# redict - redis based dictionary
# this version uses UserDict and a mostly cached redis data for low I/O impact
# almost always consistent dict. to make sure you have all latest data run __sync() periodically
# gleicon 2010 - http://zenmachine.wordpress.com - http://github.com/gleicon - http://7co.cc
import redis
from UserDict import UserDict
import time
@iangreenleaf
iangreenleaf / funcs.sh
Created August 13, 2010 20:51
Git unsigned merge hook
function error_message {
echo -e >&2 \
"---------------------------------------------------------------------------------------------------------" \
"\n$1" \
"\n---------------------------------------------------------------------------------------------------------"
}
function undo_merge {
error_message "Undoing your merge. Please fix the problem and try again."
@iangreenleaf
iangreenleaf / gist:535897
Created August 18, 2010 19:35
MySQL import with file names and progress bar
# Usage: reload-db /path/to/sqldump dbname
function reload-db {
for f in "$1"/*.sql; do
printf "%-${COLUMNS}s" "$f">&2;
cat "$f";
done \
| pv -s `du -sb "$1" | awk '{print $1}'` \
| mysql -uroot "$2";
if [ $? != 0 ]; then echo 'ERRORS!!!!!!!!!!!!!'; return $?; fi
@iangreenleaf
iangreenleaf / .gitconfig
Created September 20, 2010 21:30
Better diffs in git
[diff "ruby"]
wordRegex = (@@?|\\b:|[^:]:)?[[:alnum:]_]+|:\"[^\"]+\"|::|[^[:space:]]
[diff "php"]
wordRegex = \\${0,2}[[:alnum:]_]+|::|->|[^[:space:]]
@iangreenleaf
iangreenleaf / .gitconfig
Created October 23, 2010 00:11
My .gitconfig
[core]
excludesfile = /Users/ian/.gitignore
[color]
ui = auto
[alias]
co = checkout
st = status
br = branch
ci = commit
m = checkout master
@iangreenleaf
iangreenleaf / scopes.md
Created March 11, 2011 17:01
Scopes are awesome (stop writing SQL)

Stop writing SQL

Refresher

named_scope in 2.x.

named_scope :active, :conditions => { :status => "activo" }

Just scope now.

scope :active, where( :status => "activo" )

@iangreenleaf
iangreenleaf / gist:935741
Created April 21, 2011 23:58
Git interrogation oneliners
# Cumulative totals of lines added/deleted
git log --numstat STARTING_HASH..ENDING_HASH -M | grep '^[0-9]\+[[:space:]]\+[0-9]\+[[:space:]]' | awk '{added+=$1} {deleted+=$2} END { print added, deleted }'