Skip to content

Instantly share code, notes, and snippets.

View wangzuo's full-sized avatar
🎯
Focusing

Wang Zuo wangzuo

🎯
Focusing
View GitHub Profile
We couldn’t find that file to show.
@wangzuo
wangzuo / switch_server
Last active August 29, 2015 14:05
switch between nginx and apache
NGINX=$(ps aux | grep -c nginx)
if [ $NGINX -eq 1 ]
then
echo 'stop apache, start nginx';
sudo apachectl stop; sudo nginx;
else
echo 'stop nginx, start apache';
sudo nginx -s stop; sudo apachectl start;
fi
'use strict';
var $ = require('gulp-load-plugins')();
var _ = require('lodash');
var fs = require('node-fs-extra');
var gulp = require('gulp');
var handlebars = require('handlebars');
var path = require('path');
gulp.task('handlebars', () => {
@wangzuo
wangzuo / gulpfile.js
Created November 3, 2014 04:27
gulp locales
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var declare = require('gulp-declare');
var rename = require('gulp-rename');
var locales = ['nb_NO', 'nn_NO'];
locales.forEach(function(locale) {
gulp.task(locale, function() {
@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 %>))', {
}, {
@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;
});
};
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
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) {

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

Basic

Project structure

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