Skip to content

Instantly share code, notes, and snippets.

@jspaper
jspaper / git_tutorial.md
Last active November 16, 2017 07:30
Git tutorial
git config --local credential.helper store
git config http.sslVerify false

git remote -v
git remote set-url origin https://..../example.git

# 取得遠端的branch並在本地端建立一個branch
git checkout --track -b feature_branch origin/feature_branch
@jspaper
jspaper / caching.md
Created October 13, 2017 04:46
Caching

Caching

1. Client-side caching

  • max-age
  • etag
  • last_modified

max-age

@jspaper
jspaper / vagrant_ubuntu.md
Last active August 21, 2017 13:28
Vagrant ubuntu

vagrant ubuntu/xenial64

sudo apt-get -y update
sudo apt-get install -y build-essential zlib1g-dev curl git-core sqlite3 libsqlite3-dev

sudo apt-get install -y libssl-dev libreadline-dev
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
@jspaper
jspaper / vagrant.md
Created August 17, 2017 09:47
Vagrant
mkdir -p /Users/joshchang/Documents/vagrant_box
vagrant package --output /Users/joshchang/Documents/vagrant_box/mybox.box
vagrant box add mybox /Users/joshchang/Documents/vagrant_box/mybox.box

# New project
vagrant init mybox
vagrant up
@jspaper
jspaper / example.html
Last active January 12, 2016 06:43
Simple Picowork app
<html>
<head>
<style type="text/css">
ul li {
margin-bottom: 10px;
cursor: move;
}
</style>
</head>
@jspaper
jspaper / application_controller.rb
Last active December 26, 2015 02:29
把mobile的request一律只render page#home (layout是mobile.html),之後就統一由angular接管route。
class ApplicationController < ActionController::Base
before_filter :mobile_view_redirect
layout :which_layout
def mobile_device?
request.user_agent =~ /Mobile|webOS|Android/
end
helper_method :mobile_device?
@jspaper
jspaper / gist:3606389
Created September 3, 2012 02:42
mysql operations
# 查foreign key
# login in mysql
mysql -u root -p
use information_schema;
select TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME from KEY_COLUMN_USAGE where REFERENCED_TABLE_NAME = '<TABLE NAME>';
# 列出wed_development的所有FK
SELECT i.TABLE_SCHEMA, i.TABLE_NAME, i.CONSTRAINT_TYPE, i.CONSTRAINT_NAME, k.REFERENCED_TABLE_NAME, k.REFERENCED_COLUMN_NAME
FROM information_schema.TABLE_CONSTRAINTS i
LEFT JOIN information_schema.KEY_COLUMN_USAGE k ON i.CONSTRAINT_NAME = k.CONSTRAINT_NAME
@jspaper
jspaper / nginx
Created June 24, 2012 03:16
nginx instruction
# install nginx in OSX
brew install nginx
PATH=$PATH:/usr/local/sbin
nginx start
nginx -V # 查看配置文件位置及版本
nginx -c filename # 指定配置文件
nginx -s [reload|reopen|stop|quit]
@jspaper
jspaper / YahooToken.rb
Created May 25, 2012 14:18
yahoo api with oauth-plugin
class YahooToken < ConsumerToken
YAHOO_SETTINGS={
:site => "https://api.login.yahoo.com",
:request_token_path => "/oauth/v2/get_request_token",
:access_token_path => "/oauth/v2/get_token",
:authorize_path=> "/oauth/v2/request_auth"
}
def self.consumer
@jspaper
jspaper / redis-server
Created May 16, 2012 06:14
redis-server init.d script fork from https://github.com/ijonas/dotfiles
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db