Skip to content

Instantly share code, notes, and snippets.

View schnell18's full-sized avatar

Justin Zhang schnell18

View GitHub Profile
@schnell18
schnell18 / wxperl_build_binary.bat
Last active December 30, 2015 18:19
Sample script to use cava packager to build standalone wx_perl binary.
@echo off
set PATH=C:\Program Files\Cava Packager 2.0\bin;D:\strawberryperl\perl\bin;D:\utils;%PATH%
echo %PATH%
set RET=0
for /F %%i in ('where perl') do set PERL_EXE=%%i
for /F %%i in ('cd') do set WS_DIR=%%i
set PERL_EXE=%PERL_EXE:\=/%
set WS_DIR=%WS_DIR:\=/%
@schnell18
schnell18 / fix_git_email.sh
Created December 12, 2013 02:56
This script fixes the email in commit history. Usage: fix_git_eamil.sh <old_email> <new_email>
#!/bin/bash
# This script changes the emails of author and committer
# from the first argument to the second
old=$1
new=$2
if [[ -z $old ]]; then
echo "The original email is expected!"
exit 1
fi
@schnell18
schnell18 / git_update_hook
Last active December 31, 2015 12:09
Git update hook to validate comment starts with ticket number. It also serves as VREF so that it can work with gitolite without overwrite gitolite's fine-grained access control.
#!/usr/bin/perl
use strict;
my $refname = $ARGV[0];
my $oldrev = $ARGV[1];
my $newrev = $ARGV[2];
my $rc = 0;
my $cmd = "git rev-list ";
@schnell18
schnell18 / to_annotated_tag.sh
Created December 25, 2013 14:19
This script converts lightweight tags migrated from Subversion to annotated tags. It also moves the tag to it parent commit which is identical to itself. This makes the git describe works as expected.
#!/bin/bash
echo "Convert lightweight tag to annotated tag..."
for tg in $(git tag |grep REL)
do
newtag=${tg#REL_}
newtag=${newtag//_/.}
cmt=$(git log -1 --pretty=%s $tg)
tagger=$(git log -1 --pretty=%an $tg)
tagmail=$(git log -1 --pretty=%ae $tg)
@schnell18
schnell18 / ftpes.sh
Created January 10, 2014 03:05
cURL script to do ftpes
# Ignore certificate error and use active mode
# The "-P -" option instructs curl to use active mode
# The "--ftp-ssl" option instructs curl to use SSL V2
# The "-k" option instructs curl to ignore server certificate error
curl -v -k -P - --ftp-ssl -T ftp_hook.md ftp://uca:uca@vmcentos64
@schnell18
schnell18 / mulit-row-insert.sql
Created January 11, 2014 14:02
Multi-row insert syntax examples for various DBMS
-- Oracle flavor
insert all
into t (col1, col2, col3) values ('val1_1', 'val1_2', 'val1_3')
into t (col1, col2, col3) values ('val2_1', 'val2_2', 'val2_3')
into t (col1, col2, col3) values ('val3_1', 'val3_2', 'val3_3')
.
.
.
select 1 from dual;
@schnell18
schnell18 / handout.tex
Created January 15, 2014 13:03
Sample handout LaTex script
\documentclass[a4paper]{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages=1-last,nup=2x3,landscape=false,frame=true,
noautoscale=true,scale=0.7,delta=4mm 5mm]{slides-handout.pdf}
\end{document}
@schnell18
schnell18 / mv_master.sh
Created February 14, 2014 01:30
Replace master branch with different name. If you want to set up master branch with a different name, try these commands.
git checkout master
git checkout -b <NEW_NAME_FOR_MASTER>
git symbolic-ref HEAD refs/heads/<NEW_NAME_FOR_MASTER>
git branch -D master
@schnell18
schnell18 / reset.css
Created February 16, 2014 15:54
The well-known reset.css
/* reset browser styles */
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p,
blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn,
em, img, ins, kbd, q, s, samp,small, strike, strong, sub, sup, tt, var,
b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas,
details, embed, figure, figcaption, footer, header, hgroup, menu, nav,
output, ruby, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
@schnell18
schnell18 / get_branch_name.sh
Created February 18, 2014 06:58
Get current branch name in script
# Quirk and dirty solution
git branch | grep '*'
# Use Git's plumbing command
git rev-parse --abbrev-ref HEAD