Skip to content

Instantly share code, notes, and snippets.

@tessro
tessro / redis-server
Created December 16, 2009 14:20
A CentOS initscript for Redis
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid
@jcsrb
jcsrb / gist:1081548
Created July 13, 2011 23:05
get avatar from google profiles, facebook, gravatar, twitter, tumblr
function get_avatar_from_service(service, userid, size) {
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )
// everything else will go to the fallback
// google and gravatar scale the avatar to any site, others will guided to the next best version
@neilj
neilj / gist:1532562
Created December 29, 2011 07:22
Sugared DOM: Better Than Templates
var el = ( function () {
var doc = document;
var directProperties = {
'class': 'className',
className: 'className',
defaultValue: 'defaultValue',
'for': 'htmlFor',
html: 'innerHTML',
@adammw
adammw / README.md
Created August 3, 2012 06:30
Node.js for Raspberry Pi

Node.js for Raspberry Pi

Pre-built binaries

Recent releases have been pre-built using cross-compilers and this script and are downloadable below.

If you have found these packages useful, give me a shout out on twitter: @adammw

@zbinlin
zbinlin / toChineseNumerals.js
Created December 2, 2014 13:54
数字转大写
function toChineseNumerals(num) {
if (!/^(\d+)(?:\.(\d{1,2}))?$/.test(num)) return "";
var m = RegExp["$1"], n = RegExp["$2"];
var a = ["", "萬", "億", "兆", "京", "垓", "秭", "穰", "沟", "涧", "正", "载"];
var b = ["", "十", "百", "千"];
var c = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"];
var d = ["角", "分"];
return "(大写)" + m.split("").reverse().join("").match(/.{1,4}/g).map(function (item, index, array) {
return b.reduceRight(function (prev, cur, idx, arr) {
return prev += c[item[idx] >>> 0] + cur;