Skip to content

Instantly share code, notes, and snippets.

View encoreshao's full-sized avatar

Encore Shao encoreshao

View GitHub Profile
@encoreshao
encoreshao / README.rd
Last active August 29, 2015 14:05 — forked from jterrace/xvfb
Linux xvfb
### Step 1: Install xvfb
> # apt-get install xvfb
### Step 2: Create and enable the init script for the xvfb daemon
Note “:0″ in XVFBARGS which sets to display 0, and the –set-guid parameter, which runs the daemon as the www-data user. If you are not running a headless server, make sure to change all references to “:0″ to “:#” (ie: :1, :2 or :22) to avoid conflicts with your existing X session(s)
Move xvfb_v2 to in “/etc/init.d/xvfb”:
@encoreshao
encoreshao / deploy_rails_app_on_ubuntu.md
Last active August 29, 2015 14:26 — forked from davidguttman/deploy_rails_app_on_ubuntu.md
Setup Rails application production environment on Ubuntu

Setup Rails application production environment on Ubuntu

Add deploy user

ssh root@YOURDOMAIN
adduser deploy
visudo # Add deploy ALL=(ALL) ALL

Install necessary libraries

@encoreshao
encoreshao / mac_dev.txt
Last active April 11, 2017 00:48
setup the Mac development environment
# Setting sublime line 3
### 下载链接 - https://www.sublimetext.com/3
### 创建别名 `subl`
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
### Install package control
source link:https://packagecontrol.io/installation
open sublime - show console
@encoreshao
encoreshao / Dockerfile
Created April 28, 2017 09:26
PostgreSQL 9.6 Dockerfile
FROM ubuntu
# MAINTAINER email#dot.com
# Add the PostgreSQL PGP key to verify their Debian packages.
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
# Add PostgreSQL's repository. It contains the most recent stable release
# of PostgreSQL, ``9.6``.
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
@encoreshao
encoreshao / PG-Dockerfile
Created April 28, 2017 09:28
How to create a basic docker image on a Mac
1. Write Dockerfile
Download PG9.6 - Dockerfile (https://gist.github.com/encoreshao/3859bffca218994bb26a82015f76f150)
2. Make a docker image command
> Docker build --rm = true -t postgres: 9.6.
3. Run PostgreSQL On Docker - (5433: 5432) Local Port 5433 Mapping 5432 in docker
> Docker run -i -t -p 5433: 5432 postgres: 9.6
@encoreshao
encoreshao / mixing_query_in_postgreSQL.sql
Created June 2, 2017 08:39
Mixing query in PostgreSQL (join tables)
SELECT salesforce_accounts.*, salesforce_tasks.*, salesforce_accounts.id AS salesforce_account_id, salesforce_tasks.id AS salesforce_task_id FROM "salesforce_accounts"
LEFT JOIN salesforce_tasks ON salesforce_accounts.salesforce_id = salesforce_tasks.account_id
LEFT JOIN companies ON companies.salesforce_id = salesforce_accounts.salesforce_id
WHERE
(
(
salesforce_tasks.owner_id = 'xxxxxxxxxxxxx'
AND salesforce_tasks.is_deleted = 'f'
AND salesforce_tasks.activity_date <= '2017-06-11'
AND salesforce_tasks.activity_date >= '2017-04-04'
@encoreshao
encoreshao / compression(zip)
Created November 12, 2017 10:10
Zip excluding specific directories
## Zip excluding specific directories
Exclude *.git* file and *node_modules* directory
$ zip -r9 [target_file] [source_file] -x *.git* node_modules/\*
Exclude *.git* file and files in *node_modules* directory, but keep *node_modules* directory
$ zip -r9 [target_file] [source_file] -x *.git* node_modules/**\*
@encoreshao
encoreshao / linux_fun.md
Created November 30, 2017 18:26 — forked from marianposaceanu/linux_fun.md
How to have some fun using the terminal.

Linux fun-o-matic

How to have some fun using the terminal.

  1. Install cowsay [0] via : sudo apt-get install cowsay
  2. Install fortune [1] via : sudo apt-get install fortune
  3. Make sure you have Ruby installed via : ruby -v
  4. Install the lolcat [2] via : gem gem install lolcat
  5. Profit!
@encoreshao
encoreshao / jquery_with_delay_function.js
Last active December 21, 2017 06:05
Keyup Function with Delay
// in Javascript file
var realtimeSearchWithDelay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
@encoreshao
encoreshao / postgres_commands.sql
Last active March 28, 2018 01:44
Useful PostgreSQL Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'