Skip to content

Instantly share code, notes, and snippets.

View andrewle's full-sized avatar

Andrew Le andrewle

View GitHub Profile
@andrewle
andrewle / gir.rb
Created October 2, 2009 18:41
Add all removed files in a git tree to the index with 'git rm'
#!/usr/local/bin/ruby -w
# Find any deleted but not index files in the git status output
# and add them to the index using the 'git rm' command
# USAGE: gir
`git status`.each do |s, flag|
flag = true if s.include? '# Changed but not updated:'
`git rm #{s.gsub(/#.*deleted:\s*/, '')}` if s.include? 'deleted:'
end
require 'net/http'
require 'uri'
# POST /api/v1/:format/new
# GET /api/v1/:format/gists/:user
# GET /api/v1/:format/:gist_id
res = Net::HTTP.post_form(URI.parse('http://gist.github.com/api/v1/xml/new'),
{ 'files[file1.ab]' => 'CONTNETS',
'files[file2.ab]' => 'contents' })
find . -type f -iname "*.php" -path "./controllers/*" -or -path "./models/*" -or -path "./views/*" -or -path "./tests/*" | xargs wc -l | grep 'total' | awk '{print $1}'
# Add xml extensions to all files in the directory
# '-I %' switch specifies '%' as a replacement character all instances of '%'
# will be replaced with the argument
ls -1 | xargs -I % mv % %.xml
#! /usr/bin/env ruby
# A quick little ruby script to run in the shell to have your existing
# local branch track a remote branch
# Ex: git-track add origin master
# git-track remove origin master
if ARGV.empty? or ARGV.length < 3
puts "USAGE: git-track [add|remove] <remote-name> <branch-name>\n\n"
exit
end
function slideShow(elem) {
return (function () {
var next_elem = (elem.next().length > 0) ? elem.next() : $('#slide-images p:first');
elem.fadeOut(1000);
next_elem.fadeIn(1000);
setTimeout(slideShow(next_elem), 5000);
})
}
$(document).ready(function () {
# Rename a bunch of pngs to add leading 0's
#!/usr/bin/env ruby
`ls -1 *.png`.each_line do |l|
`mv #{l.strip} #{l.strip.sub(/_(\d5)(\.|_)/, '_0\1\2')}` if l.match(/_\d5(\.|_)/)
end
#!/usr/bin/env ruby
# Something to do for the gist command line script:
# Add a method that lists all your gists in the same way that git log does it
#!/usr/bin/env bash
#
# Ignored .svn directories
# Also ignored .DS_Store files from Mac file system
# Add the --dry-run argument if you want to just test it first
DOMAIN="phototourwebsites@phototourwebsites.com"
DIR="/home/phototourwebsites/www/phototoursmls/idx_dev_andrew"
rsync -avz \
# A rough and dirty baseline Rails app template
# I just discovered this feature and love it
remove_files = [
"public/index.html",
"public/images/rails.png",
"public/javascripts/controls.js",
"public/javascripts/dragdrop.js",
"public/javascripts/effects.js",
"public/javascripts/prototype.js"