Skip to content

Instantly share code, notes, and snippets.

@clonn
clonn / routeDeploy.js
Last active March 7, 2021 08:01
Node.js with Express, deploy through web hook. this is route part code.
var exec = require('child_process').exec;
var set = function (app) {
app.post('/deploy', function (req, res) {
var feedback;
var branch = 'master';
try {
feedback = JSON.parse(req.body.payload);
@clonn
clonn / net.js
Created June 4, 2013 09:56
dynamic callback answer example
fs = require('fs');
var sandbox = {};
vm.runInNewContext(data, sandbox);
socket.on('data',function(data){
// after proccessed data, left the callback function name.
callback = JSON.parse(fs.readFileSync('./' + data));
callback.fn();
});
# 1. Create a new file at /Library/LaunchDaemons/org.mongo.mongod.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.mongo.mongod</string>
<key>RunAtLoad</key>
<true/>
@clonn
clonn / org.redis.redis-server.plist
Created April 23, 2013 05:25
redis-server plist in MacOS, can check my blog, http://blog.caesar.com
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.redis.redis-server</string>
<key>Program</key>
<string>/usr/local/bin/redis-server</string>
<key>ProgramArguments</key>
@clonn
clonn / send_mail.coffee
Created April 13, 2013 00:24
Node.js, Send mail by Gmail. it is a simple code in Coffee Script, a full content for Node.js Taiwan Community contributor.
nodemailer = require 'nodemailer'
fs = require 'fs'
_sendMail = (email, code) ->
contentHtml = [
"親愛的 Node.js 台灣社群朋友,"
"<p>"
"由於你的支持,社群活動才能夠得以持續進行,因此特別送上 JSDC 邀請碼,"
"<br/>"
"<br/>"
@clonn
clonn / lolcommits fail issue.sh
Last active December 15, 2015 17:39
lolcommits enable or disable fail issue
$lolcommits --disable
dyld: Library not loaded: /usr/local/lib/libjpeg.8.dylib
Referenced from: /usr/local/bin/mogrify
Reason: image not found
/Library/Ruby/Gems/1.8/gems/mini_magick-3.5.0/lib/mini_magick.rb:26:in `image_magick_version': private method `split' called for nil:NilClass (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/mini_magick-3.5.0/lib/mini_magick.rb:34:in `valid_version_installed?'
from /Library/Ruby/Gems/1.8/gems/lolcommits-0.4.3/lib/lolcommits/configuration.rb:137:in `valid_imagemagick_installed?'
from /Library/Ruby/Gems/1.8/gems/lolcommits-0.4.3/bin/lolcommits:43:in `die_on_fatal_conditions!'
@clonn
clonn / speaker.js
Last active December 15, 2015 15:09
JSDC 2013 Speaker
var Speakers = [
{
"name": "Kuro Hsu",
"job": "",
"topic": "Optimizing Your Mobile Web Apps."
},
{
"name": "Paul Li",
"job": "",
"topic": "樸實與浮華 (Plain and Vanity)"
@clonn
clonn / yeoman_grunt_bower.md
Last active December 15, 2015 00:49
usage for yoeman, grunt, bower

#Yoeman, bower, grunt.js cli tool usage

Installation, node.js and npm are required.

npm install -g yo grunt-cli bower

compass is a sass compoments of ruby, and you can install compass by rubygem

gem install compass
@clonn
clonn / app.js
Last active December 14, 2015 16:29
node.js express, muliti-middleware method, node.js express,多層 middleware 使用方法
var express = require('express'),
routes = require('./routes'),
http = require('http'),
server;
var app = express();
app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
@clonn
clonn / http_flush.js
Created December 6, 2012 17:19
response a http flush data on node.js
var http = require('http')
http.createServer(function (req, res) {
(function () {
res.write('hello world \n');
setTimeout(arguments.callee, 500);
})();
}).listen(3000, '127.0.0.1');