Skip to content

Instantly share code, notes, and snippets.

Avatar

lemonhall lemonhall

View GitHub Profile
View nanomsg 整体结构分析
last edit: 20140822 15:11
本文分析的代码是 nanomsg-0.4-beta版本。
要创建一个 PUB/SUB 服务,只需要六个 API,分别是:
1. nn_socket
2. nn_bind
3. nn_connect
4. nn_send
5. nn_recv
6. nn_close
View backend-architectures.md
View 1 Instructions for compiling node0.8.8 with hardfloat.md

These instructions work for the Raspberry Pi running Raspbian (hard float) and create a hardware optimized version of NodeJS for the Raspberry PI, (and include a working install and NPM!!!):

  1. Install Raspbian - http://www.raspberrypi.org/downloads

  2. Install the necessary dependecies:

sudo apt-get install git-core build-essential

(If you just installed git then you need to administer your git identity first, else adding the patches below will fail!!!)

@lemonhall
lemonhall / gist:3120320
Created Jul 16, 2012
FormData for XMLHttpRequest 2 - Polyfill for Web Worker (c) 2012 Rob W
View gist:3120320
/*
* FormData for XMLHttpRequest 2 - Polyfill for Web Worker (c) 2012 Rob W
* License: Creative Commons BY - http://creativecommons.org/licenses/by/3.0/
* - append(name, value[, filename])
* - toString: Returns an ArrayBuffer object
*
* Specification: http://www.w3.org/TR/XMLHttpRequest/#formdata
* http://www.w3.org/TR/XMLHttpRequest/#the-send-method
* The .append() implementation also accepts Uint8Array and ArrayBuffer objects
* Web Workers do not natively support FormData:
@lemonhall
lemonhall / arraybuffer-blob-filereader-localStorage.js
Created Jul 14, 2012 — forked from robnyman/arraybuffer-blob-filereader-localStorage.js
Get file as an arraybuffer, create blob, read through FileReader and save in localStorage
View arraybuffer-blob-filereader-localStorage.js
// Getting a file through XMLHttpRequest as an arraybuffer and creating a Blob
var rhinoStorage = localStorage.getItem("rhino"),
rhino = document.getElementById("rhino");
if (rhinoStorage) {
// Reuse existing Data URL from localStorage
rhino.setAttribute("src", rhinoStorage);
}
else {
// Create XHR, BlobBuilder and FileReader objects
var xhr = new XMLHttpRequest(),
@lemonhall
lemonhall / request302.js
Created Jun 27, 2012
get a 302 location
View request302.js
var http = require('http');
var url='http://r.autobloglink.com/?u=aHR0cDovL3BpYy5oYW5pbWFnZS5jb20vZGFiYWdpcmwvRFJFU1MvRGExMDcwNC8yLmpwZw==';
http.get(url, function(res) {
console.log("Got response: " + res.statusCode);
if(res.statusCode===302){
console.log(res.headers.location);
}
}).on('error', function(e) {
console.log("Got error: " + e.message);
@lemonhall
lemonhall / encode2gb2312.js
Created Oct 5, 2011
非常特殊的GB2312/GBK 的URIencode函数
View encode2gb2312.js
function encodeToGb2312(str){
var strOut="";
for(var i = 0; i < str.length; i++){
var c = str.charAt(i);
var code = str.charCodeAt(i);
if(c==" ") strOut +="+";
else if(code >= 19968 && code <= 40869){
index = code - 19968;
strOut += "%" + z.substr(index*4,2) + "%" + z.substr(index*4+2,2);
}
You can’t perform that action at this time.