Skip to content

Instantly share code, notes, and snippets.

var crypto = require('crypto');
/**
* Calculates the hash/checksum of a string. Default algorithm is MD5.
*
* @param {String} str
* @param {String} algorithm
* @return {String} checksum
* @api public
*/
(function() {
var EventEmitter = require('events').EventEmitter;
var inspect = require('util').inspect;
var emit_ = EventEmitter.prototype.emit;
EventEmitter.prototype.emit = function(name) {
var args = Array.prototype.slice.call(arguments);
if (!(this === process.stderr && name === 'drain')) {
console.error("Event '%s', arguments: %s",
name, inspect(args.slice(1), false, 1));
}
find dir -type f -print0 | xargs -0 md5sum | sort
;(function ($, window) {
var intervals = {};
var removeListener = function(selector) {
if (intervals[selector]) {
window.clearInterval(intervals[selector]);
intervals[selector] = null;
}
@liyu1981
liyu1981 / static_server.js
Last active August 29, 2015 13:59 — forked from ryanflorence/static_server.js
simple, and native way, to fast build a http server in nodejs
// forked, and make it worable under nodejs >= 0.8
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs"),
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
@liyu1981
liyu1981 / gist:06338d33a5947851918d
Last active August 29, 2015 14:01 — forked from thomseddon/gist:3511330
Angularjs filter for: number => bytes/kB/MB/GB/TB/PB
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
}
});
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
chroot /var/lib/haproxy
user haproxy
group haproxy
daemon
#debug
#quiet
import time
import struct
import socket
import hashlib
import base64
import sys
from select import select
import re
import logging
from threading import Thread
#!/bin/sh
# Sublime Text 3 install with Package Control
# http://simonewebdesign.it/blog/install-sublime-text-3-on-fedora-20/
# Run this script with:
# $ curl LINK_TO_THIS_SCRIPT | sh
curl -o ~/st3.tar.bz2 http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3059_x64.tar.bz2
@liyu1981
liyu1981 / README.md
Last active August 29, 2015 14:09 — forked from dariocravero/README.md

Create a Meteor app and put the client_/server_ files in a client/server directories. Also, create a public dir to save the uploaded files.