Skip to content

Instantly share code, notes, and snippets.

@JoshuaChi
JoshuaChi / npm.taobao.sh
Last active December 22, 2017 03:29 — forked from 52cik/npm.taobao.sh
npm 淘宝镜像配置
npm set registry https://registry.npm.taobao.org # 注册模块镜像
npm set disturl https://npm.taobao.org/dist # node-gyp 编译依赖的 node 源码镜像
## 以下选择添加
npm set chromedriver_cdnurl http://cdn.npm.taobao.org/dist/chromedriver # chromedriver 二进制包镜像
npm set operadriver_cdnurl http://cdn.npm.taobao.org/dist/operadriver # operadriver 二进制包镜像
npm set phantomjs_cdnurl http://cdn.npm.taobao.org/dist/phantomjs # phantomjs 二进制包镜像
npm set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass # node-sass 二进制包镜像
npm set electron_mirror http://cdn.npm.taobao.org/dist/electron/ # electron 二进制包镜像
npm set selenium_cdnurl=http://npm.taobao.org/mirrors/selenium
@JoshuaChi
JoshuaChi / postgres-cheatsheet.md
Created August 23, 2017 09:17 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@JoshuaChi
JoshuaChi / consist_hash.java
Created June 1, 2017 14:20 — forked from bcambel/consist_hash.java
Consistent Hash Java implementation
import java.util.Collection;
import java.util.SortedMap;
import java.util.TreeMap;
public class ConsistentHash<T> {
private final HashFunction hashFunction;
private final int numberOfReplicas;
private final SortedMap<Integer, T> circle = new TreeMap<Integer, T>();
@JoshuaChi
JoshuaChi / LeastConnectionBalancer.java
Created April 9, 2017 08:18
Zookeeper::LeastConnectionBalancer
public class LeastConnectionBalancer implements Balancer {
private CuratorFramework zkClient;
public LeastConnectionBalancer(CuratorFramework zkClient){
this.zkClient = zkClient;
}
@Override
public String select() throws Exception {
@JoshuaChi
JoshuaChi / RoundRobinBalancer.java
Created April 9, 2017 08:17
Zookeeper::RoundRobinBalancer
public class RoundRobinBalancer implements Balancer {
private CuratorFramework zkClient;
public RoundRobinBalancer(CuratorFramework zkClient){
this.zkClient = zkClient;
}
@Override
public String select() throws Exception {
@JoshuaChi
JoshuaChi / gist:82acf99323dfd49af7929c0c218fe4ff
Created December 31, 2016 07:55 — forked from kaiwren/gist:1283905
Steve Yegge's SOA post
From: https://raw.github.com/gist/933cc4f7df97d553ed89/24386c6a79bb4b31fb818b70b34c5eab7f12e1ff/gistfile1.txt
Stevey's Google Platforms Rant
I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.
I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various effort
@JoshuaChi
JoshuaChi / multi-process
Created January 2, 2016 09:35
Shell Multi Process
#!/bin/bash
set -m # Enable Job Control
WORKSPACE="$( cd "$( dirname "${BASH_SOURCE[0]}" )/" && pwd )"
for i in `seq 8`; do # start 8 jobs in parallel(e.g. 8 cores)
//sh example.sh
done
@JoshuaChi
JoshuaChi / GetCsvDataFromYahoo.java
Created March 19, 2015 14:25
GetCsvDataFromYahoo
package finance.datainit.util;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.SocketException;
import java.net.URL;
import java.net.URLConnection;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@JoshuaChi
JoshuaChi / default.conf
Last active August 29, 2015 14:14 — forked from cbmd/default.conf
server {
index index.php;
set $basepath "/var/www";
set $domain $host;
# check one name domain for simple application
if ($domain ~ "^(.[^.]*)\.dev$") {
set $domain $1;
set $rootpath "${domain}";

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin