Skip to content

Instantly share code, notes, and snippets.

Chen Chia Yang Unayung

Block or report user

Report or block Unayung

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
@Unayung
Unayung / service.rb
Created Jul 21, 2017
General Interface for crawler
View service.rb
class LearningPlatformService
include ColorgyCrawler::DateMixin
def initialize(user)
@user = user
account = user.learning_platform_datum.account
password = Base64.decode64(Base64.decode64(user.learning_platform_datum.password))
lp_klass = LearningPlatform.find!(user.organization_code)
@lp_instance = lp_klass.new(account, password)
@lp_data = @user.learning_platform_datum
@Unayung
Unayung / pchome.rb
Created Jul 13, 2017
pchome 商品資訊抓取
View pchome.rb
require 'capybara'
require 'capybara/dsl'
include Capybara::DSL
Capybara.javascript_driver = :selenium
Capybara.current_driver = :selenium
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :firefox)
end
@Unayung
Unayung / go.rb
Last active Jul 6, 2017
go.rb 解說
View go.rb
require 'nokogiri'
require 'rest-client'
url = "http://www.appledaily.com.tw/realtimenews/section/sports/" # 一開始的進入點
base_url = "http://www.appledaily.com.tw" # 網站的基本網址
raw_data = RestClient.get(url)
data = Nokogiri::HTML(raw_data.body)
page_links = data.css('nav.page_switch a') # 底下分頁 1,2,3,4,5 的 a 元素
i = 0
@Unayung
Unayung / welcome.rb
Last active Jul 6, 2017
welcome.rb 解說
View welcome.rb
name = ARGV[0] #第一個參數
name ||= "" # 如果 name 已經存放東西,就保持原樣,如果 name 沒有存放東西,則將 "" 存放進去
birthday = ARGV[1] #第二個參數
birthday ||= ""
msg = name + " Welcome to X-Program"
msg = msg + " " + Time.now.to_s # .to_s 代表轉換為字串
puts "="* msg.size # .size 計算前面的物件的長度 msg.size 代表計算 msg 這個字串的總長度
View g4h-customize.txt
Feature:
Partners get their own Graphical Interface while using the Golf4Holland System – which means both in frontend and in backend it needs to have the look and feel of the partner. But without any change in layouts of pages.
What must partners be able to do?
• They can invoice their customers
o Collect the money on their own bank account and pay Golf4Holland a fee pp
o G4H collects the money on a separate account and pays Golf4Holland and the partners a fee pp
@Unayung
Unayung / rvm2rbenv.txt
Created Apr 22, 2016 — forked from brentertz/rvm2rbenv.txt
Switch from RVM to RBENV
View rvm2rbenv.txt
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@Unayung
Unayung / nokogiri install
Created Mar 25, 2016
gem install nokogiri issue
View nokogiri install
If previously installed, uninstall the gem:
$ gem uninstall nokogiri
Use Homebrew to install libxml2, libxslt and libiconv:
$ brew install libxml2 libxslt libiconv
Install the gem specifying the paths to the libraries to be linked against:
$ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"
View CSV Import
1. 使用 Office for Mac 開啟 Excel 檔案.
2. 如有亂碼情況,先選取全部資料,將字型改為「蘋果儷中黑」可以消除亂碼情況.
3. 將無亂碼的檔案按下 「檔案」-> 「另存新檔」 格式選擇 Windows Comma Separated (.csv)
4. 如果 Excel 檔有多張 sheet, 會跳警告, 請確認只轉存第一張 sheet
5. 確認存檔後即可以此份 CSV 進行商品大量上傳.
View gist:6156570
[[ -s /Users/Unayung/.rvm/scripts/rvm ]] && source /Users/Unayung/.rvm/scripts/rvm
alias pro='cd ~/Dropbox/projects'
alias ll='ls -l'
alias mou='open -a Mou'
alias blog='cd ~/projects/octopress'
alias linode='ssh root@106.186.18.211'
alias rhodes='ssh root@106.187.88.48'
alias mini='ssh rocodev@rocodevtekiMac-mini.local'
alias aeus='ssh -i ~/Downloads/ae-us-east.pem ubuntu@ec2-107-22-15-86.compute-1.amazonaws.com'
alias github='open http://github.com/unayung'
View gist:6147132
/*
On OS X, basic text manipulations (left, right, command+left, etc) make use of the system key bindings,
and don't need to be repeated here. Anything listed here will take precedence, however.
*/
[
{ "keys": ["super+shift+n"], "command": "new_window" },
{ "keys": ["super+shift+w"], "command": "close_window" },
{ "keys": ["super+o"], "command": "prompt_open" },
{ "keys": ["super+shift+t"], "command": "reopen_last_file" },
{ "keys": ["super+alt+up"], "command": "switch_file", "args": {"extensions": ["cpp", "cxx", "cc", "c", "hpp", "hxx", "h", "ipp", "inl", "m", "mm"]} },
You can’t perform that action at this time.