Skip to content

Instantly share code, notes, and snippets.

View terrywang's full-sized avatar

Terry Wang terrywang

View GitHub Profile
@matthewmccullough
matthewmccullough / gist:47267
Created January 15, 2009 05:15 — forked from halbtuerke/gist:31934
Show Git dirty status in your Unix bash prompt (symbols not compatible with CygWin)
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
@sit
sit / gitproxy-socat
Created January 20, 2009 02:30
A simple wrapper around socat to use as a git proxy command
#!/bin/sh
# Use socat to proxy git through an HTTP CONNECT firewall.
# Useful if you are trying to clone git:// from inside a company.
# Requires that the proxy allows CONNECT to port 9418.
#
# Save this file as gitproxy somewhere in your path (e.g., ~/bin) and then run
# chmod +x gitproxy
# git config --global core.gitproxy gitproxy
#
# More details at http://tinyurl.com/8xvpny
# backup_db.rb
# Remotely back up and securely download a copy of a MySQL database.
# Can be used in conjunction with cron to run nightly with a crontab like this:
# 0 0 * * * ruby /home/user/scripts/backup_db.rb
# Written by C. Scott Andreas (http://twitter.com/cscotta)
# No warranties, use entirely at your own risk. The author assumes no liability
# for any consequences of this script, including data loss, security breaches, and service unavailability.
# Released under an MIT-style License. Use, modify, and distribute this script as you like.
@colinux
colinux / subtitles-renamer.sh
Created January 27, 2011 23:21
Rename subtitles files according to tv shows names found in a directory
#!/bin/bash
# Renames subtitles files according to tv shows names found in a directory
# Acceped syntaxes for season/episode are: 304, s3e04, s03e04, 3x04 (case insensitive)
#
# Usage:
# Put this gist somewhere in your $PATH, like /usr/local/bin/subtitles-renamer
# Chmod +x it
# cd ~/YourHolidaysTvShowsWithSubtitles
# subtitles-renamer
@SaitoWu
SaitoWu / runable.rb
Created February 11, 2011 08:57
exec something on ruby.
#0> non-block call
Thread.new do
blahbla...
end
#1> 4 simple ways to call shell or cmd
`ps aux`
@SaitoWu
SaitoWu / eigenclass.rb
Created March 16, 2011 07:53
some ruby meta programming demo.
#Person
class Person
end
#class method
class Person
def self.address
puts "hangzhou"
end
end
@SaitoWu
SaitoWu / proc.rb
Created March 17, 2011 14:44
magic ruby proc demo
def block_new
puts Proc.new.call
end
block_new{"hello"}
#slow practice
def herp_pass_block(&block)
derp_call_block &block
end
@SaitoWu
SaitoWu / fibers.rb
Created June 28, 2011 05:47
ruby fibers exercise
require 'fiber'
fib = Fiber.new do
v = 0
loop do
v += 1
Fiber.yield v
v.times { print "-"}
puts v
end
@smoser
smoser / README.md
Last active October 12, 2020 17:14
ubuntu-auto-install: install a ubuntu image with kvm

Ubuntu Auto Install

This allows user to do automated installation of ubuntu. Provided here a a few different files/scripts for making this easier.

I've used this to verify that d-i kernel and initramfs from -proposed work as shown in bug 1511497.

The provided 'preseed' below can be used as a fully automated installation of ubuntu. Boot with qemu like:

note python web server is useful for this (python -m SimpleHTTPServer 9999)

@mhayes
mhayes / bootstrap.sh
Created July 30, 2011 20:01
Bootstrap CentOS 5.5 w/Ruby 1.9 and Chef
#!/bin/bash
# bootstrap ruby1.9 on a fresh RHEL5.5/CentOS5.5
# installs chef and bundler as well
# warning: this script does NOT make you breakfast
#enable EPEL repo, some packages (i.e. ruby-mysql) depend on this
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
RUBY_19_VERSION="ruby-1.9.2-p180"