Skip to content

Instantly share code, notes, and snippets.

@wohugb
wohugb / gist:4661734
Created January 29, 2013 04:14
Hello World!
echo "Hello World!";
@wohugb
wohugb / mgidxexpsec
Created January 21, 2014 14:29
MongoDB设置过期索引
db.log.events.ensureIndex( { "createdAt": 1 }, { expireAfterSeconds: 3600 } )
<?php
// Determine ENV
define('APPLICATION_ENV', getenv('APPLICATION_ENV') == 'development' || PHP_SAPI == 'cli' ? 'development' : 'production');
// Load the appropriate config file
return
APPLICATION_ENV == 'development' ?
require __DIR__.'/application.development.config.php' :
require __DIR__.'/application.production.config.php'
;
@wohugb
wohugb / yeoman
Created March 1, 2014 15:15
如何安装yeoman
如果出现错误:`sh "-c" "node ./scripts/doctor"` failed with 127
ln -s /usr/bin/nodejs /usb/bin/node
npm i -g yeoman
function encrypt(text,key){
var cipher = crypto.createCipher('aes-256-cbc',key)
var crypted = cipher.update(text,'utf8','hex')
crypted += cipher.final('hex');
return crypted;
}
function decrypt(text,key){
var decipher = crypto.createDecipher('aes-256-cbc',key)
var dec = decipher.update(text,'hex','utf8')

MacOS

Build 3059

MD5: 59bab8f71f8c096cd3f72cd73851515d

Rename it to: Sublime Text

Make it executable with: chmod u+x Sublime\ Text

@wohugb
wohugb / app.js
Created November 18, 2014 08:39
how to use koa.js+mongoose 如何使用?
var koa = require('koa')
, mongoose = require('mongoose')
, Blog = require('./models/blog')
;
//连接数据库
var uris = 'mongodb://192.168.1.2/db,mongodb://192.168.1.3/db';
var options = {
db: { native_parser: true },
server: {'auto_reconnect': true,'poolSize': 10},
@wohugb
wohugb / Chat application
Last active August 29, 2015 14:10
聊天应用
#聊天应用
##入门
In this guide we’ll create a basic chat application. It requires almost no basic prior knowledge of Node.JS or Socket.IO, so it’s ideal for users of all knowledge levels.
## 介绍
Writing a chat application with popular web applications stacks like LAMP (PHP) has traditionally been very hard. It involves polling the server for changes, keeping track of timestamps, and it’s a lot slower than it should be.
Sockets have traditionally been the solution around which most realtime chat systems are architected, providing a bi-directional communication channel between a client and a server.
@wohugb
wohugb / array.js
Last active August 29, 2015 14:12
js数组
//JS在1.6中为Array新增了几个方法map(),filter(),some(),every(),forEach()
//@ref http://www.cnblogs.com/xiao-hong/p/3194027.html
map()//:返回一个新的Array,每个元素为调用func的结果
filter()//:返回一个符合func条件的元素数组
some()//:返回一个boolean,判断是否有元素是否符合func条件
every()//:返回一个boolean,判断每个元素是否符合func条件
@wohugb
wohugb / yo.sh
Created February 26, 2015 02:50
安装yo,报yodoctor: Permission denied的解决办法
npm config set unsafe-perm true