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 / 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';
@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

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 / 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

Basic

Project structure

  • app.js
  • app.json
  • app.wxss
  • /pages

Rails 5

ruby

  • Rails 5 requires Ruby 2.2.2 or newer. (2.2.4 or 2.3.0)
  • reduce memory usage by taking advantage of GC
  • gem update --system
var fs = require('fs');
var path = require('path');
var mustache = require('mustache');
var onebox = require('onebox');
// custom render method for preview
var preview = onebox({
render: function(engine, data, cb) {
var tpath = path.join(__dirname, 'templates', engine+'.mustache');
fs.readFile(tpath, function(err, buf) {
use strict; use warnings;
use HTML::Strip;
use Devel::Peek;
use Test::More tests => 3;
use Encode;
use utf8;
=head1 Workaround for HTML::Strip with utf8
@wangzuo
wangzuo / String.prototype.format.js
Created November 20, 2014 11:07
String.prototype.format
if(!String.prototype.format) {
String.prototype.format = function() {
var cnt = 0;
var args = arguments;
return this.replace(/(\%s)/g, function(match) {
var term = typeof args[cnt] !== 'undefined' ? args[cnt] : match;
cnt++;
return term;
});
};
@wangzuo
wangzuo / gupfile.js
Created November 4, 2014 06:16
gulp handlebar partials
var gulp = require('gulp');
var concat = require('gulp-concat');
var handlebars = require('gulp-handlebars');
var wrap = require("gulp-wrap");
gulp.task('partials', function() {
return gulp.src('templates/partials/*.html')
.pipe(handlebars())
.pipe(wrap('Handlebars.registerPartial("<%= fname(file) %>", Handlebars.template(<%= contents %>))', {
}, {