Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Wen-Tien Chang ihower

🏠
Working from home
Block or report user

Report or block ihower

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View my_tweet.rb
# gem install twitter
require 'twitter'
# https://apps.twitter.com/
client = Twitter::REST::Client.new do |config|
config.consumer_key = "...."
config.consumer_secret = "...."
end
def collect_with_max_id(collection=[], max_id=nil, &block)
View gist:c044da01e7a05e01cdf29917833ca7de
{"zh-CN"=>"简体中文", "zh-TW"=>"繁體中文", "ja"=>"日本語", "de"=>"Deutsch", "en"=>"English", "es"=>"Español", "fr"=>"Français", "it"=>"Italiano", "nl"=>"Nederlands", "pl"=>"polski", "pt"=>"Português", "tr"=>"Türkçe", "ru"=>"Русский", "ar"=>"العربية", "th"=>"ไทย", "ko"=>"한국어", nil=>"所有語言", "ach"=>"Acoli", "af"=>"Afrikaans", "ak"=>"Akan", "ay"=>"Aymara", "az"=>"azərbaycan", "ms"=>"Bahasa Melayu", "ban"=>"Balinese", "bho"=>"Bihari", "x-bork"=>"Bork, bork, bork!", "bs"=>"bosanski", "br"=>"brezhoneg", "ca"=>"català", "ceb"=>"Cebuano", "cs"=>"Čeština", "sn"=>"chiShona", "co"=>"Corsican", "cy"=>"Cymraeg", "da"=>"Dansk", "yo"=>"Èdè Yorùbá", "et"=>"eesti", "eo"=>"esperanto", "eu"=>"euskara", "ee"=>"Eʋegbe", "x-elmer"=>"Ewmew Fudd", "fil"=>"Filipino", "fo"=>"føroyskt", "gaa"=>"Ga", "ga"=>"Gaeilge", "gd"=>"Gàidhlig", "gl"=>"galego", "gn"=>"Guarani", "ht"=>"Haitian Creole", "ha"=>"Hausa", "hr"=>"Hrvatski", "haw"=>"ʻŌlelo Hawaiʻi", "bem"=>"Ichibemba", "ig"=>"Igbo", "rn"=>"Ikirundi", "id"=>"Indonesia", "ia"=>"Interlingua", "zu"=>"is
View gist:a8f0e5cfcec37ec42ac20a4f2aa14d2a
# 输入一个数组,表示每种书买本书,例如 [1,2,0,0,0] 是第一集买一本、第二集买两本
def book_price(order)
price = [0, 1 * 100, 0.95 * 200, 0.9 * 300, 0.8 * 400, 0.75 * 500 ]
order = order.reject{ |x| x <= 0 }
if order.size == 0
return 0
else
kind = order.count{ |x| x > 0 }
min_size = order.min
View gist:7c003373fa8db8fc8ee8a55a48a4b537
# https://github.com/mrzool/bash-sensible
source ~/.sensible.bash
alias stree='/Applications/SourceTree.app/Contents/Resources/stree'
alias x="exit"
alias c="clear"
export LC_ALL=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
@ihower
ihower / hello.rb
Last active May 11, 2016
a ruby example
View hello.rb
"你好".force_encoding(Encoding::GB18030).encode(Encoding::UTF_8)
# => "浣犲ソ"
View gist:e66f664b9f4925fb6754
// golang 1.5.1
// go run hello.go
package main
import (
"fmt"
"log"
"net/http"
)
View gist:517818a8bb670ef639b3
sendfile on;
tcp_nopush on;
tcp_nodelay on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
gzip_disable "msie6";
gzip_comp_level 5;
View gist:a12d2b174fbe4fa049d2
# http://blog.orangeapple.tw/posts/what-is-computational-thinking/
# 設計一個「從0開始慢慢找出X」的流程 (設計演算法),如下:
# 1. 先寫下“輸入=17”、“答案=0”、“位數=1”
# 2. 把“答案”乘以自己,看看有沒有超過“輸入”:
# 2-1. 是:將“答案”減“位數”,跳到第3步
# 2-2. 否:將“答案”加“位數”,跳回第2步
# 3. 看看“答案”乘上“答案”的結果與“輸入”是否相差0.1以內:
# 3-1. 是:跳到第4步
# 3-2. 否:將“位數”除以10,跳回第2步
View gist:593611ffa5cedc6d8409
target = "@2x"
Dir.glob("*.png").sort.each do |entry|
if File.basename(entry, File.extname(entry)).include?(target)
newEntry = entry.gsub(target, "")
File.rename( entry, newEntry )
puts "Rename from " + entry + " to " + newEntry
end
end
View gist:9ffe9b86ef49d104fc12
class Parent
def hi(name)
puts "I'm parent"
puts "Hi, #{name}"
end
end
class Child < Parent
def hi
You can’t perform that action at this time.