Code examples from this stack overflow answer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var requirejs = require('requirejs'); | |
| requirejs.config({ | |
| nodeRequire: require | |
| }); | |
| requirejs(['express', 'connect', 'connect-redis'], function(express, connect, ConnectRedis) { | |
| var app = express.createServer(); | |
| var RedisStore = new ConnectRedis(express); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| use Encode 'encode_utf8'; | |
| my $s = ' ' . encode_utf8(pack 'U', 0x2605); | |
| my $f = encode_utf8(pack 'U', 0xFF0F); | |
| my $b = encode_utf8(pack 'U', 0xFF3C); | |
| my $o = [ map { encode_utf8(pack 'U', $_) } ( | |
| 0x0069, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Module dependencies. | |
| */ | |
| var express = require('express') | |
| , routes = require('./routes') | |
| , http = require('http') | |
| , mongoose = require('mongoose') | |
| , path = require('path'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Pikachu.js | |
| // 테러범들에겐 백만볼트! | |
| // 사용법__________________________ | |
| // 사용법은 간단하다. "var pikachu = require("Pikachu.js");"로 초기화 한 후 http.createServer에다가 붙여주면 된다. | |
| // req와 res는 알다시피 request와 response. :) | |
| // 특정 사이트에서 공격이 들어온다거나 할 때 http referer를 바탕으로 검열(?!) 쯤 해준다고 보면 된다. | |
| // 차단하기 쉽도록 유명한 사이트들은 미리 정규표현식을 만들어놨다. 필요할 때 요긴하게 쓸 수 있다. | |
| exports.dcinside = '/(.+?)dcinside.com/'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function () { | |
| "use strict"; | |
| // for better performance - to avoid searching in DOM | |
| var content = $('#content'); | |
| var input = $('#input'); | |
| var status = $('#status'); | |
| // my color assigned by the server | |
| var myColor = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>jsonp test</title> | |
| <script src="http://code.jquery.com/jquery-1.6.2.min.js"></script> | |
| <script type="text/javascript"> | |
| $(function(){ | |
| $('#select_link').click(function(e){ | |
| e.preventDefault(); | |
| console.log('select_link clicked'); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # (Re)spawn the application | |
| function spawn () { | |
| local ps_name=$1 | |
| local spawn_cmd=$2 | |
| local pids=`ps -C $ps_name -o pid=` | |
| if [ ${#pids} -ne 0 ] | |
| then | |
| echo "Sending TERM to $pids..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var xmpp = require('node-xmpp'), | |
| secret = require('./secret'), | |
| util = require('util'); | |
| var creds = { | |
| jid: '[email protected]', | |
| password: secret.pw, //string | |
| }; | |
| var GChat = function(creds) { |
Here's how this works:
- Include a
git_hooks/directory in your project, with these two files (plus other hooks if you want, written in a similar style). - Add
"npm"to yourdevDependenciesinpackage.json, so that thepre-commithook can do its magic. - Add
testandlintscripts to yourpackage.json, e.g.
"scripts": {
"test": "mocha",
"lint": "jshint ./lib --show-non-errors"