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 / 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() {
'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 / 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
We couldn’t find that file to show.
function sendError(message, url, lineNum) {
var i;
// First check the URL and line number of the error
url = url || window.location.href;
lineNum = lineNum || 'None';
// If the error is from these 3rd party script URLs, we ignore
// We could also just ignore errors from all scripts that aren't our own
var scriptURLs = [
@wangzuo
wangzuo / nginx.conf
Last active August 29, 2015 14:02 — forked from Stanback/nginx.conf
server {
listen 80;
listen [::]:80;
server_name yourserver.com;
root /path/to/your/htdocs;
error_page 404 /404.html
index index.html;
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
# NEW WAY / EASY WAY
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.1.0.deb
sudo dpkg -i elasticsearch-1.1.0.deb
@wangzuo
wangzuo / pubsub.md
Created February 27, 2014 11:14 — forked from addyosmani/pubsub.md

#Four Ways To Do Pub/Sub With jQuery and jQuery UI (in the future)

Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.

(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)

##Option 1: Using jQuery 1.7's $.Callbacks() feature:

$.Callbacks are a multi-purpose callbacks list object which can be used as a base layer to build new functionality including simple publish/subscribe systems. We haven't yet released the API documentation for this feature just yet, but for more information on it (including lots of examples), see my post on $.Callbacks() here:

/*
highlight v3 !! Modified by Jon Raasch (http://jonraasch.com) to fix IE6 bug !!
Highlights arbitrary terms.
<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
MIT license.
@wangzuo
wangzuo / debource.js
Created December 22, 2013 05:40
javascript debounce function
(function($, sr){
// debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced () {
var obj = this, args = arguments;
function delayed () {