Skip to content

Instantly share code, notes, and snippets.

View schnell18's full-sized avatar

Justin Zhang schnell18

View GitHub Profile
@schnell18
schnell18 / netcat_gitlist
Created November 19, 2013 14:16
simple script using netcat to simulate browser
cat << EOF | nc vmcentos64 80 > gitlist_landing_page.txt
GET /gitlist/ HTTP/1.1
Host: vmcentos64
User-Agent: netcat
EOF
@schnell18
schnell18 / mk_sshkeys.sh
Last active December 28, 2015 22:49
Bash script to generate SSH public/private key pairs for a bunch of users.
#!/bin/sh
# read the user name from stdin line by line
while read u
do
rm -f ${u}
rm -f ${u}.pub
ssh-keygen -t rsa -b 2048 -N "" -C "SSH keypair for $u" -f ${u}
done
@schnell18
schnell18 / my_gitconfig.txt
Last active December 28, 2015 23:49
Useful git config to work on OSX
git config --global user.name "John Doe"
git config --global user.email "[email protected]"
git config --global core.editor vim
git config --global color.ui true
git config --global merge.tool vimdiff
git config --global push.default simple
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
@schnell18
schnell18 / mv_remote_refs_up
Created November 24, 2013 05:52
Move the remote refs created by the git svn migration tool(git svn clone --no-metadata --authors-file -s) to their local refs
for entry in $(git for-each-ref --format="%(objectname)|%(refname)")
do
oldref=$(echo $entry | cut -d '|' -f 2)
if [[ $oldref =~ 'remotes' ]]; then
sha=$(echo $entry | cut -d '|' -f 1)
if [[ $oldref =~ 'remotes/tags' ]]; then
newref=$(echo $oldref | sed -e 's/remotes\/tags/tags/')
elif [[ $oldref =~ 'remotes' ]]; then
newref=$(echo $oldref | sed -e 's/remotes/heads/')
fi
@schnell18
schnell18 / fix_commit_msg.sh
Created November 25, 2013 06:03
Format the commit message to follow "ticket: short comment" pattern.
git filter-branch --msg-filter 'perl -e '\''while(<>) {print join(q/: /, split(/\s*:\s*/, $_, 2))}'\''' -- --all
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
@schnell18
schnell18 / svn_to_git_post_migration.sh
Last active December 29, 2015 09:39
This script is sample Subversion to Git migration scripts to perform references relocation, bad commit message fix, lost merge history restore etc.
#!/bin/bash
# This script should be launched under the top level git directory.
function clean_up() {
rm -fr .git/svn
rm -fr .git/info/grafts
git branch -d trunk
git gc
}
@schnell18
schnell18 / find_unmerged.sh
Created November 29, 2013 12:38
Find all branches not yet merged into current branch. It is equivalent of git branch --no-merged
for t in $(git for-each-ref --format="%(refname)")
do
c=$(git rev-list HEAD..$t)
if [[ ! -z $c ]]; then
echo $t
fi
done
@schnell18
schnell18 / check_rebase.sh
Created December 4, 2013 05:00
Bash script to determine if current branch need rebase changes from the integration branch.
#!/bin/bash
# Bash script to determine if current branch(default HEAD)
# need rebase the changes from the integration
# branch(default master)
# Author: Justin Zhang <[email protected]>
# Created: 2013-12-04
#
# Usage:
# check_rebase.sh [current branch] [integration branch]
#
@schnell18
schnell18 / get_patch.sh
Last active December 30, 2015 13:29
Shell script to archive full source of last changed files.
#!/bin/bash
base=$1
archive=$2
currentBranch=$(git rev-parse --abbrev-ref HEAD)
currentBranch=${currentBranch//heads\//}
if [[ -z $base ]]
then
base=bl_${currentBranch}
@schnell18
schnell18 / rc.conf
Created December 8, 2013 11:40
Sample FreeBSD network interface configuration
hostname="vmfreebsd92"
ifconfig_em0="DHCP"
ifconfig_em1="inet 192.168.56.104 netmask 255.255.255.0"
defaultrouter="192.168.1.1"
sshd_enable="YES"
ntpd_enable="YES"