Skip to content

Instantly share code, notes, and snippets.

@ptantiku
ptantiku / conv_bin2str.s
Last active August 29, 2015 14:15
Convert bit stream into ASCII string
#####################################################################
# converting bit stream into ascii string #
# author: ptantiku #
# #
# compile: gcc conv_bin2str.s -o conv_bin2str #
# usage: conv_bin2str <binary string> #
# example: conv_bin2str 0110100001100101011011000110110001101111 #
#####################################################################
.data
@ptantiku
ptantiku / caesar_solve.rb
Created July 14, 2014 17:26
Caesar Cipher
def shift(str, n)
before = [*'a'..'z'].join
after = [*'a'..'z'].rotate(n).join
str = str.tr(before, after).tr(before.upcase, after.upcase)
return str
end
str = 'Myxqbkdevkdsyxc, iye wkno sd!!'
26.times{|i|
puts "#{i}: #{shift(str,i)}"
for i in {1..36}
do
curl -s http://www.etda.or.th/etda_website/category/publications.html/page:$i | \
grep -P 'content.*class="news"' | \
sed -re 's/ +//g' -e 's/^.*href="([^"]+)".*>(.*)<\/a>.*/\2\thttp:\/\/www.etda.or.th\1/'
done | tee out.txt
@ptantiku
ptantiku / gist:3ef85b4bae7431e77f72
Created May 2, 2014 07:32
counting down time in minutes & seconds to a specific time (ex. 16:00)
watch -n 1 'diff=$(( $(date +%s -d "16:00") - $(date +%s) )); echo $(( $diff / 60 ))":"$(( $diff % 60 ))'
@ptantiku
ptantiku / emolist.js
Created March 31, 2014 16:02
Javascript to print out all emoticons on Facebook. Usage: open javascript console on the browser (e.x. ctrl+shift+j) then paste the code in.
var emolist=[
{"chars" : " :) ", "class" : "emoticon_smile", "name" : "Smiley"},
{"chars" : " :( ", "class" : "emoticon_frown", "name" : "Frown"},
{"chars" : " :P ", "class" : "emoticon_tongue", "name" : "Tongue"},
{"chars" : " :D ", "class" : "emoticon_grin", "name" : "Grin"},
{"chars" : " :o ", "class" : "emoticon_gasp", "name" : "Gasp"},
{"chars" : " ;) ", "class" : "emoticon_wink", "name" : "Wink"},
{"chars" : " :v ", "class" : "emoticon_pacman", "name" : "Pacman"},
{"chars" : " >:( ", "class" : "emoticon_grumpy", "name" : "Gruñón"},
{"chars" : " :/ ", "class" : "emoticon_unsure", "name" : "Unsure"},
@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
@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 / 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 / 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 / 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;
}