Skip to content

Instantly share code, notes, and snippets.

View hanksudo's full-sized avatar
:octocat:
Follow your passion.

Hank Wang hanksudo

:octocat:
Follow your passion.
View GitHub Profile
@hanksudo
hanksudo / send_public_key_to_remote.sh
Created April 19, 2016 11:07
Copy public ssh key to remote
cat ~/.ssh/id_rsa.pub | ssh pi@raspberrypi.local "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
@hanksudo
hanksudo / list_supported_fonts.swift
Created April 15, 2016 18:07
List all supported fonts on iOS
for (familyName) in UIFont.familyNames() {
print("\nFamily: ", familyName.utf8)
let fontNames = UIFont.fontNamesForFamilyName(familyName)
for (fontName) in fontNames {
print("\tFont: ", fontName.utf8)
}
}
@hanksudo
hanksudo / twse.sh
Created February 2, 2016 18:33
TWSE - simple demo
#!/bin/sh
http -f POST http://www.twse.com.tw/ch/trading/exchange/FMNPTK/FMNPTKMAIN.php download=csv CO_ID=2103 > 2103.csv
iconv -f big5 -t utf-8 2103.csv > 2103-utf8.csv
@hanksudo
hanksudo / is-github-down.sh
Created January 29, 2016 04:40
Check if GitHub is down
#!/bin/sh
if curl -s -o /dev/null -I http://github.com; then
echo " 🐈 It's up. Go back to work!"
else
echo " 🦄 It's down. Go outside!"
fi
@hanksudo
hanksudo / grab-origin-image-url.go
Last active January 29, 2016 07:20
Grab origin image url from Instagram / Facebook
package main
import (
"fmt"
"log"
"net/http"
"github.com/PuerkitoBio/goquery"
)
@hanksudo
hanksudo / check_http_status.sh
Last active January 22, 2016 02:34
Check HTTP status with emoji
#!/bin/sh
set -e
URIS="""/
/news
"""
HTTP_OK=0
HTTP_TIMEOUT=0
@hanksudo
hanksudo / google-translate-api.sh
Last active January 17, 2016 17:31
Google Translate API shell script
#!/bin/sh
usage ()
{
echo 'Usage :'
echo "\t$0 Text"
exit
}
if [ "$#" -ne 1 ]
then
@hanksudo
hanksudo / shell_script_for_cronjob.sh
Created December 21, 2015 09:59
cron job shell script demo
#!/bin/bash
. /home/hanksudo/.virtualenvs/starthack/bin/activate
set -e
project_dir="$(cd "$(dirname "$0")/.."; pwd)"
cd "$project_dir"
exec starthack 1 2
@hanksudo
hanksudo / install-chef-solo-by-ruby-gem-in-china.sh
Created November 25, 2015 13:00
install chef-solo by rubygem on ubuntu in China (aliyun)
apt-get update
apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool bison subversion pkg-config libffi-dev vim -y
# install ruby
cd /tmp
wget https://ruby.taobao.org/mirrors/ruby/ruby-2.2.2.tar.gz
tar -zxvf ruby-*.tar.gz
cd ruby-*
./configure --prefix=/usr/local
make
@hanksudo
hanksudo / ViewController.swift
Created October 29, 2015 04:48
(Swift) NSTimer count
import UIKit
class ViewController: UIViewController {
var timer = NSTimer()
var count = 0
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.