Skip to content

Instantly share code, notes, and snippets.

View bestlong's full-sized avatar

Shao Yu-Lung (Allen) bestlong

View GitHub Profile

git-cheat-sheet

基本操作

git init <目錄>

git clone <repo>

git config user.name 
@bestlong
bestlong / selenium-php-webdriver-cheatsheet.md
Last active April 25, 2018 05:08 — forked from aczietlow/selenium-php-webdriver-cheatsheet.md
Cheat sheet for using php webdriver (facebook/webdriver).

Webdriver PHP API workthough

  • Open a browser

    # start an instance of firefox with selenium-webdriver
    
    $browser_type = 'firefox'
    $host = 'http://localhost:4444/wd/hub'
    

$capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => $browser_type);

@bestlong
bestlong / tar-laravel-prod-app.sh
Last active September 11, 2016 04:52
Laravel 遇到 shared hosting 環境又只能透過 ftp 傳輸到主機,先做個打包壓縮處理提高上傳效率
#!/usr/bin/env bash
TAR_FILENAME=_production-upload.tar.gz
npm install
gulp --production
# 拿掉 dev 環境相依套件
composer install --prefer-dist --no-dev
@bestlong
bestlong / touch_all_linked_files.rake
Last active August 29, 2015 14:23
cap 執行過程
### lib/capistrano/tasks/touch_all_linked_files.rake
namespace :deploy do
namespace :check do
# desc 'Touches all linked files'
task :touch_all_linked_files do
on release_roles :all do
fetch(:linked_files, []).each do |file|
target = shared_path.join(file)
execute :touch, target
info "Touched : #{target}"
@bestlong
bestlong / deploy.rb
Last active August 29, 2015 14:23
Touches all linked files if not exist, use Capistrano 3.4.0
### part of config/deploy.rb
namespace :deploy do
namespace :check do
# desc 'Touches all linked files'
task :touch_all_linked_files do
on release_roles :all do
fetch(:linked_files, []).each do |file|
target = shared_path.join(file)
unless File.file?(target)
info "File.file?('#{target}') : #{File.file?(target)}"
@bestlong
bestlong / jquery-validator-twid.js
Last active August 29, 2015 14:04
jquery.validator for Taiwan ID
//增加固定長度的 validation rule
$.validator.addMethod("exactlength", function(value, element, param) {
return this.optional(element) || value.length == param;
}, $.validator.format("輸入長度必須為 {0} 個字元."));
$.validator.addMethod("checkTWPID", function(value, element, param) {
var letters = new Array('A', 'B', 'C', 'D',
'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M',
'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'X', 'Y', 'W', 'Z', 'I', 'O');