This file contains 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 convertToChinese(num) { | |
num=''+num; | |
var ret='', ret2='', zero=''; | |
var nWord=['零','一','二','三','四','五','六','七','八','九','十']; | |
var unitWord=['','十','百','千'], unitWord2=['','萬','億','兆']; | |
var rWord=[[/^一十/, '十']]; | |
var n=num.replace(/\D/g,'').split(''); | |
for(var i=0;i<n.length;i++) { | |
if(Math.floor((n.length-i-1)/4)>=unitWord2.length) { | |
ret2+= nWord[n[i]]; |
This file contains 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
timers = []; | |
var cycleImgs = function(imgs){ | |
for(var j=0;j<timers.length;j++){clearTimeout(timers[j]);} | |
var selector = '#bgimg'; | |
var gonext = function(imgarray, idx){ | |
//console.log(imgarray[idx]); | |
var nextImage = new Image(); | |
nextImage.onload = function(){ | |
$(selector).stop().animate({opacity : 0 }, | |
250, |
This file contains 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 entry(metadata) | |
local postname = '_posts/' .. metadata.ref .. '.lua' | |
local pubdate = os.date("*t", metadata.pubdate) | |
print('Processing ' .. postname) | |
local convertedname = '_posts/' .. pubdate.year .. '-' | |
.. pubdate.month .. '-' | |
.. pubdate.day .. '-' | |
.. metadata.ref .. '.html' | |
print('Converting file into ' .. convertedname) | |
local f = assert(io.open(convertedname, 'w')) |
This file contains 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
require 'sinatra' | |
get(/.+/) do | |
send_sinatra_file(request.path) {404} | |
end | |
not_found do | |
send_sinatra_file('404.html') {"Sorry, I cannot find #{request.path}"} | |
end |
This file contains 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
##generator pipes | |
import re | |
import os | |
import fnmatch | |
import gzip, bz2 | |
def gen_find(filepat, top): | |
for path, dirlist, filelist in os.walk(top): | |
for name in fnmatch.filter(filelist, filepat): |
This file contains 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
++[>++++++++++[>++++++++++[>++++++++++[>++++++++++<-]<-]<-]<-]>+++++[>++++++++++[>++++++++++[>++++++++++<-]<-]<-]>>++++++++++[>++++++++++<-]>+++++.<<<++++[>++++++++++[>++++++++++[>++++++++++<-]<-]<-]>++[>++++ ++++[>++++++++<-]<-]>>.>+++++++++[>++++++++++[>++++++++++[>++++++++++<-]<-]<-]+++++++++[>+++++++++<-]>[>>-<<-]>>------[<<<<->>>>-]<<<<. |
This file contains 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
Fixing the postgresql initdb fatal shared memory error on Leopard | |
Published Tue 18 December 2007 11:09 (+1300) | |
Tagged | |
software (43 posts and 3 photos) | |
mac os x (6 posts) | |
When doing the post-install setup of postgresql default database using initdb, you may hit this error: | |
FATAL: could not create shared memory segment: Cannot allocate memory | |
DETAIL: Failed system call was shmget(key=1, size=1646592, 03600). |
This file contains 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
<!doctype html> | |
<html> | |
<head> | |
<!-- Encoding --> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame --> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></meta> | |
This file contains 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
General principles for good URI design: | |
Don't use query parameters to alter state | |
Don't use mixed-case paths if you can help it; lowercase is best | |
Don't use implementation-specific extensions in your URIs (.php, .py, .pl, etc.) | |
Don't fall into RPC with your URIs | |
Do limit your URI space as much as possible | |
Do keep path segments short | |
Do prefer either /resource or /resource/; create 301 redirects from the one you don't use | |
Do use query parameters for sub-selection of a resource; i.e. pagination, search queries |
This file contains 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
// Helper function, used below. | |
// Usage: ['img1.jpg','img2.jpg'].remove('img1.jpg'); | |
Array.prototype.remove = function(element) { | |
for (var i = 0; i < this.length; i++) { | |
if (this[i] == element) { this.splice(i,1); } | |
} | |
}; | |
// Usage: $(['img1.jpg','img2.jpg']).preloadImages(function(){ ... }); | |
// Callback function gets called after all images are preloaded |
OlderNewer