Skip to content

Instantly share code, notes, and snippets.

View terrywang's full-sized avatar

Terry Wang terrywang

View GitHub Profile
@chrismeller
chrismeller / ping.conf
Created February 9, 2013 20:02
My PHP-FPM pool.d config files.
[www]
ping.path = /ping
@smoser
smoser / gist:4756561
Last active November 8, 2023 15:20
boot a cloud image in kvm
## Install a necessary packages
$ sudo apt-get install kvm cloud-utils genisoimage
## URL to most recent cloud image of 12.04
$ img_url="http://cloud-images.ubuntu.com/server/releases/12.04/release"
$ img_url="${img_url}/ubuntu-12.04-server-cloudimg-amd64-disk1.img"
## download the image
$ wget $img_url -O disk.img.dist
## Create a file with some user-data in it
#curl -L https://gist.github.com/karlentwistle/5029263/raw/84faa6a15a9c521533e33135090c1214c457f08d/chef_solo_bootstrap.sh | bash
aptitude -y update
echo "Installing RVM and Ruby dependencies"
sudo apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion git-core libgdbm-dev pkg-config libffi-dev
echo "Installing RVM system-wide"
bash -c "bash <( curl -L https://github.com/wayneeseguin/rvm/raw/1.3.0/contrib/install-system-wide ) --version '1.3.0'"
cat >> /etc/profile <<'EOF'
# Load RVM if it is installed,
# first try to load user install
@Jerry-Fix
Jerry-Fix / ubuntu 12.04 preseed
Created April 13, 2013 17:03
ubuntu 12.04 preseed for cobbler
d-i debian-installer/locale string en_US
d-i debian-installer/language string en
d-i debian-installer/country string US
d-i debian-installer/locale string en_US.UTF-8
d-i debian-installer/allow_unauthenticated string true
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string us
@thbar
thbar / .bash_profile
Created May 15, 2013 13:37
How to quickly switch Mac OS X terminal background between black and white.
# based on http://stackoverflow.com/questions/549186/change-background-of-terminal-app-from-the-commandline
function darkback {
osascript -e "tell application \"Terminal\" to set background color of window 1 to {0,0,0}"
}
function lightback {
osascript -e "tell application \"Terminal\" to set background color of window 1 to {65535,65535,65535}"
}
@fields
fields / Vagrantfile
Created May 20, 2013 15:48
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# override these variables in ~/.vagrant.d/Vagrantfile for your local changes
$local_username ||= `whoami`.strip
$local_projects_directory ||= "~/projects/vagrant/"
$vm_memory ||= "4096"
$vm_cpus ||= "4"
$server_root_password = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
@smoser
smoser / apt-go-fast
Last active January 15, 2020 22:12
apt-go-fast: streamline apt-get by removing things you don't want or need and using eatmydata
#!/bin/sh
# https://gist.github.com/smoser/5823699
set -e
[ "$(id -u)" = "0" ] && sudo="" || sudo="sudo"
[ -e "/usr/bin/apt-get.distrib" ] ||
$sudo dpkg-divert --local --rename --add /usr/bin/apt-get
$sudo tee /usr/bin/apt-get >/dev/null <<"EOF"
#!/bin/sh
@rodjek
rodjek / 0_description.md
Last active December 19, 2015 03:18
check_puppet_run_health

check_puppet_run_health

A Nagios check that connects to PuppetDB and determines the Puppet agent run health on a host.

Requires

  • PuppetDB
  • A puppetmaster configured to send reports to PuppetDB

States

@huacnlee
huacnlee / move_files.rb
Last active December 20, 2015 17:49
将一个目前下面的文件,根据文件名前缀分散到不同的文件夹,比如 a12.jpg -> a/1/a12.jpg, b287.jpg -> b/2/b287.jpg 此方法用于处理由于最初设计上传文件夹没有分层次导致一个目录文件过多的问题。可以将一个目录下面的文件分散到子目录中
require "fileutils"
root_dir = "/Users/jason/Downloads/images"
Dir.chdir(root_dir)
puts Dir.pwd
Dir.glob("**/*.{jpg}").each do |fname|
tfname = fname.split("/").last
if fname.match("[small|large|normal]_")
tfname = fname.split("_").last
end
p1,p2 = tfname[0,1],tfname[1,1]
@dcai
dcai / git_update_moodle.sh
Last active October 26, 2017 03:39
git_update_moodle.sh
#!/bin/bash
# Your github username
github_user="dcai"
# The remote name of your github repo, it usually origin
github_remote_name="github"
### STOP CONFIG SINCE HERE! ###
github_diff_root="https://github.com/$github_user/moodle/compare/"