Skip to content

Instantly share code, notes, and snippets.

@ptantiku
ptantiku / rbenv_path_env
Created July 12, 2013 08:53
Script for set RBENV path (for putting in .bashrc or .zshrc)
# setup RBENV's path
export RBENV_ROOT="$HOME/.rbenv"
if [ -d "$RBENV_ROOT" ]; then
if [ -d "$RBENV_ROOT/versions/$RBENV_VERSION" ]; then
export PATH="$RBENV_ROOT/versions/$RBENV_VERSION/bin:$PATH"
export PATH="$RBENV_ROOT/shims:$PATH"
else
export PATH="$RBENV_ROOT/bin:$PATH"
export PATH="$RBENV_ROOT/shims:$PATH"
fi
@ptantiku
ptantiku / install_rbenv.sh
Last active December 19, 2015 18:18
Install RBENV
# Install development tools:
sudo apt-get update
sudo apt-get -y install build-essential git-core \
make libc6-dev libssl-dev libssl-dev \
libreadline6-dev zlib1g-dev libyaml-dev
# Install rbenv:
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
# Add rbenv to the path (for BASH):
@ptantiku
ptantiku / config_apache2_haml_sass.sh
Created July 16, 2013 03:11
Configure Apache2 to support HAML and SASS
#!/bin/bash
# enable mod_ext_filter
a2enmod ext_filter
# create temp config file
cat <<EOF > /tmp/haml_sass
# For HAML & SASS (http://d.hatena.ne.jp/ursm/20080923/1222195693)
LoadModule ext_filter_module libexec/apache2/mod_ext_filter.so
@ptantiku
ptantiku / gist:6031663
Last active December 19, 2015 22:59
q1
#!/usr/bin/env ruby
all=[*'0000'..'9999'];open('numbers.txt').each_line{|line|all[line.to_i]=nil};open('run_result.txt','w').puts all.compact!
@ptantiku
ptantiku / favicon_download.sh
Created December 19, 2013 06:58
Download top 1000 website's favicon image. Websites are ranked by Alexa.com
#!/bin/bash
wget http://s3.amazonaws.com/alexa-static/top-1m.csv.zip
unzip top-1m.csv.zip
for l in `head -n 1000 top-1m.csv`
do
host=`echo -n $l|cut -d, -f2`
wget -O "$host.ico" "http://$host/favicon.ico"
done
@ptantiku
ptantiku / A.java
Created February 22, 2014 08:22
Java integer overflow
class User{
public Integer money;
public User(Integer money){
this.money = money;
}
public Integer getMoney(){
return this.money;
}
@ptantiku
ptantiku / android_secret_codes_scan.sh
Last active August 29, 2015 13:56
Scan Android's apk files for SECRET_CODE
#!/bin/bash
###############################################################################
### For finding all secret codes in android ###
###############################################################################
# author: @ptantiku
#
# refer: http://forum.xda-developers.com/showthread.php?t=540483
#
# *****************************************************************************
@ptantiku
ptantiku / collect_rom-0.sh
Created March 2, 2014 12:51
Collecting rom-0 files and decompress
#!/bin/bash
prefix_ip='10.10.10'
#collecting
for i in `seq 1 255`
do
wget --connect-timeout=1 -t 1 -O "$prefix_ip.$i.rom-0" "http://$prefix_ip.$i/rom-0"
done
@ptantiku
ptantiku / stock_data.php
Created March 13, 2014 19:53
Download stock data from BLS
<?php
# Downloading stock data, one file per date
# required packages: php5-cli wget
# downloaded files have format of: name, date(yymmdd), open, high, low, close, volume(stocks), value(baht)
$start_year = 2003;
for($y=$start_year; $y<=2014; $y++){
for($m=1; $m<=12; $m++ ){
@ptantiku
ptantiku / temperature_pull.sh
Created March 29, 2014 18:15
Pull temperature data from Thai Meteorological Department website, from $fromdate to $todate, filtering by name of the location.
#!/bin/bash
fromdate=$(date -d 2013-08-01 +"%Y%m%d")
todate=$(date +"%Y%m%d")
filter="สนามบินสุวรรณภูมิ"
for year in {2013..2014}
do
for month in {1..12}
do