Skip to content

Instantly share code, notes, and snippets.

View ihower's full-sized avatar
🎯
Focusing

Wen-Tien Chang ihower

🎯
Focusing
View GitHub Profile
require 'pycall'
module LangChain
ChatModels = PyCall.import_module("langchain.chat_models")
LLMs = PyCall.import_module("langchain.llms")
Embeddings = PyCall.import_module("langchain.embeddings")
DocumentLoaders = PyCall.import_module("langchain.document_loaders")
TextSplitter = PyCall.import_module("langchain.text_splitter")
VectorStores = PyCall.import_module("langchain.vectorstores")
@ihower
ihower / gist:442a6d6fd968534996b8
Last active April 1, 2021 12:21
ALPHA Camp Web Development Bootcamp #3 Syllabus (draft)
{"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
# https://support.apple.com/zh-tw/HT208050
export BASH_SILENCE_DEPRECATION_WARNING=1
# https://github.com/mrzool/bash-sensible
source ~/.sensible.bash
export PATH=$HOME/bin:/usr/local/bin:/usr/local/sbin:$PATH
export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"
export PATH="/usr/local/opt/node@10/bin:$PATH"
[user]
name = Wen-Tien Chang
email = ihower@gmail.com
[alias]
co = checkout
ci = commit
st = status
br = branch -v
rt = reset --hard
# 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)
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
function git_since_last_commit {
now=`date +%s`;
last_commit=$(git log --pretty=format:%at -1 2> /dev/null) || return;
seconds_since_last_commit=$((now-last_commit));
minutes_since_last_commit=$((seconds_since_last_commit/60));
@ihower
ihower / gist:6132576
Last active June 12, 2019 05:42
Git commit without commit
# First commit
echo "hello" | git hash-object -w --stdin
git update-index --add --cacheinfo 100644 ce013625030ba8dba906f756967f9e9ca394464a hello.txt
git write-tree
git commit-tree aaa96c -m "First commit"
git update-ref refs/heads/master 30b060d9a7b5e93c158642b2b6f64b2b758da40d
# Second commit
class Parent
def hi(name)
puts "I'm parent"
puts "Hi, #{name}"
end
end
class Child < Parent
def hi
# 输入一个数组,表示每种书买本书,例如 [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