Skip to content

Instantly share code, notes, and snippets.

@ryenus
ryenus / gist:2755231
Created May 20, 2012 06:13
Install ruby and rails with rvm on Ubuntu
# install packages to get RVM
sudo apt-get install build-essential git-core curl
# install RVM
curl -L get.rvm.io | bash -s stable
# load RVM
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
source "$HOME/.rvm/scripts/rvm"
@ryenus
ryenus / codepage-test.bat
Created May 28, 2012 13:34
demo patch for JRUBY-6679
@echo off
rem cd /d e:/proj/oss/jruby
call :check_cp 437 775 850 852 855 857 860 861 862 863 864 865 866 869 1250 1251 1252 1253 1254 1255 1256 1257 1258
:check_cp
for %%e in (%*) do (
chcp %%e
for %%c in (ruby bin\jruby) do (
@ryenus
ryenus / gist:2880689
Created June 6, 2012 08:39
sqlplus without entry defined in tnsnames.ora
# Here is how to directly connect to an Oracle DB without setting up tnsname first.
#
# sqlplus "$DB_USER/$DB_PASS@(
# description=
# (
# address_list=(
# address=
# (protocol=tcp)
# (host=$DB_HOST)
# (port=$DB_PORT)))
@ryenus
ryenus / num_fmt.sh
Created July 7, 2012 09:06
format number with customizable decimal mark, group separator and group size
# Usage:
# num_formatted=`format_number 12345.6789`
# OR
# num_formatted=`format_number 12345.6789 . , 3`
format_number() {
[ $# = 0 ] && retrun
raw_num=$1
dec_mark="$2"; [ -z "$dec_mark" ] && dec_mark=.
grp_sep="$3"; [ -z "$grp_sep" ] && grp_sep=,
@ryenus
ryenus / startGroovy.bat
Created July 7, 2012 09:52
tweaking groovy launching script
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem ##
@rem Groovy JVM Bootstrap for Windowz ##
@rem ##
@rem ##########################################################################
@rem
@rem $Revision$ $Date$
@rem
@ryenus
ryenus / gist:3074393
Created July 9, 2012 05:34
find all remote branches not having a corresponding local branch
# local branches
git branch | tr '*' ' ' | tr -d ' '
# all remote branches
git branch -a | grep remotes/ | cut -d/ -f3
# subtract
grep -F -v -f <(git branch | tr '*' ' ' | tr -d ' ') <(git branch -a | grep remotes/ | cut -d/ -f3)
# insert remote name as prefix
@ryenus
ryenus / self_print.sh
Created July 10, 2012 15:29
shell script that print itself
#!/bin/sh
each_line() {
filename="$1"
func=$2
line_num=0
while read -r line; do
line_num=$((line_num + 1))
$func "$line" $line_num
done < "$filename"
@ryenus
ryenus / gist:3085059
Created July 10, 2012 17:47
rotate a tabular file to swap axis x/y
swap_xy() {
SRC_FILE="$1"
n=0
max_width=0
(while read line; do
[ -z "`echo $line`" ] && continue
n=$((n + 1))
[ $n -eq 1 ] && SEP="" || SEP=" | "
num_cells=`echo "$line" | sed "s/[^|]//g" | wc -m`
@ryenus
ryenus / gist:3098667
Created July 12, 2012 15:03
create a github token via github api v3 using curl
curl -u username -d "{}" https://api.github.com/authorizations
@ryenus
ryenus / gist:3110142
Created July 14, 2012 09:09
clean up old kernel images in ubuntu
dpkg -l linux-image-* | awk '/^ii/ {print $2}' | grep -v $(uname -r) | xargs sudo apt-get -y purge
sudo update-grub2
#sudo dpkg --clear-avail