Skip to content

Instantly share code, notes, and snippets.

View wangzuo's full-sized avatar
🎯
Focusing

Wang Zuo wangzuo

🎯
Focusing
View GitHub Profile
@wangzuo
wangzuo / http2_ubuntu_trusty.md
Last active November 8, 2016 05:10
http2 ubuntu trusty

openssl

nginx

  • http://nginx.org/en/download.html
  • `./configure —user=nginx —group=nginx —prefix=/etc/nginx —sbin-path=/usr/sbin/nginx —modules-path=/usr/lib/nginx/modules —conf-path=/etc/nginx/nginx.conf —error-log-path=/var/log/nginx/error.log —http-log-path=/var/log/nginx/access.log —pid-path=/var/run/nginx.pid —lock-path=/var/run/nginx.lock —http-client-body-temp-path=/var/cache/nginx/client_temp —http-proxy-temp-path=/var/cache/nginx/proxy_temp —http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp —http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp —http-scgi-temp-path=/var/cache/nginx/scgi_temp —user=nginx —group=nginx —with-compat —with-file-aio —with-threads —with-http_addition_module —with-http_auth_request_module —with-http_dav_module —with-http_flv_module —with-http_gunzip_module —with-htt

Rails mailer guide

Notice

  • email styling is hard outlook-margins
  • url helper
  • config.action_mailer.asset_host
  • assets:precompile on sidekiq server
  • <img alt="" /> with image disabled by default
  • encrypt helper for token
@wangzuo
wangzuo / local_development_setup.md
Created December 20, 2016 04:39
local_development_setup

brew

  • brew install dnsmasq
  • brew install nginx

dnsmasq

# /usr/local/etc/dnsmasq.conf
no-dhcp-interface=
server=8.8.8.8
addn-hosts=/usr/local/etc/dnsmasq.hosts
@wangzuo
wangzuo / index.ios.js
Created January 12, 2017 14:49
react-reform-native
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
TextInput,
Button
} from 'react-native';
import defaultValidations from './react-reform/opt/validations';
### Keybase proof
I hereby claim:
* I am wangzuo on github.
* I am wangzuo (https://keybase.io/wangzuo) on keybase.
* I have a public key ASDILDRXcYHkQy6BMHRZifQ9sx63vh2ezWuskninGdITzwo
To claim this, I am signing this object:
@wangzuo
wangzuo / web-servers.md
Created June 26, 2017 06:01 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@wangzuo
wangzuo / accounting.js
Last active June 12, 2018 06:14
opaque types in flow
// @flow
export opaque type AccountBalance = number;
export opaque type AccountNumber: number = number;
export opaque type PaymentAmount: number = number;
// export opaque type AccountNumber = number;
// export opaque type PaymentAmount = number;
type Account = {
accountNumber: AccountNumber,
balance: AccountBalance,
export interface IRPCProvider {
getNetVersion(): Promise<string>;
ping(): Promise<boolean>;
getBalance(address: string): Promise<Wei>;
estimateGas(tx: Partial<IHexStrTransaction>): Promise<Wei>;
getTransactionCount(address: string): Promise<string>;
getTransactionByHash(txhash: string): Promise<TransactionData>;
getTransactionReceipt(txhash: string): Promise<TransactionReceipt>;
sendRawTx(tx: string): Promise<string>;
sendCallRequest(txObj: TxObj): Promise<string>;
@wangzuo
wangzuo / bot-pr.js
Created June 29, 2018 06:46
Github bot pr
GitHub.prototype.writeFile = function (filePath, data, branch, commitTitle) {
branch = branch || this.options.branch
commitTitle = commitTitle || 'Add Staticman file'
return this.api.repos.createFile({
user: this.options.username,
repo: this.options.repository,
path: filePath,
content: Buffer.from(data).toString('base64'),
message: commitTitle,
@wangzuo
wangzuo / mad.js
Created October 16, 2018 07:26
Minimum Absolute Difference
// Minimum Absolute Difference in an Array
// comparing each pair O(n^2)
// sort first O(nlogn) + O(n)
exports.mad = function(arr) {
const a = arr.sort((a, b) => a - b);
let min = -1;
for (let i = 0, l = a.length; i < l - 1; i++) {
const d = Math.abs(a[i] - a[i + 1]);
if (min < 0 || d < min) {