Skip to content

Instantly share code, notes, and snippets.

Avatar

Nathan Rajlich TooTallNate

View GitHub Profile
@TooTallNate
TooTallNate / gist:752646
Created Dec 23, 2010
"Target architecture arm is only supported on arm and ia32 host"?
View gist:752646
[51/72] libv8.a: deps/v8/SConstruct -> build/default/libv8.a
/usr/bin/python "/Users/nrajlich/node/tools/scons/scons.py" -j 1 -C "/Users/nrajlich/node/build/default/" -Y "/Users/nrajlich/node/deps/v8" visibility=default mode=release arch=arm library=static snapshot=on
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o obj/release/accessors.o -c -Wall -W -Wno-unused-parameter -Wnon-virtual-dtor -pedantic -O3 -fomit-frame-pointer -fdata-sections -ffunction-sections -ansi -mmacosx-version-min=10.4 -fno-rtti -fno-exceptions -Wall -W -Wno-unused-parameter -Wnon-virtual-dtor -pedantic -O3 -fomit-frame-pointer -fdata-sections -ffunction-sections -ansi -mmacosx-version-min=10.4 -DV8_TARGET_ARCH_ARM -DENABLE_VMSTATE_TRACKING -DENABLE_LOGGING_AND_PROFILING -DENABLE_DEBUGGER_SUPPORT -I/Users/nrajlich/node/deps/v8/src /Users/nrajlich/node/deps/v8/src/accessors.cc
In file included from /Users/nrajlich/node/deps/v8/src/v8globals.h:31,
from /Users/
@TooTallNate
TooTallNate / example.js
Created Feb 10, 2011
'connect's "vhost" middleware, modified to accept a generic handler function. Works well with "stack".
View example.js
var vhost = require('vhost');
var stack = require('stack');
var foo = function(req, res) {
// Do something...
}
var bar = function(req, res) {
// Do something else...
}
View per-stack-error-handlers.js
var http = require('http');
var Stack = require('stack');
var stack1 = Stack(
// Layers...
);
stack1.errorHandler = function(req, res, err) {
res.writeHead(404);
res.end('Not Found Custom');
}
@TooTallNate
TooTallNate / starttls.js
Created Mar 1, 2011
Upgrade a regular `net.Stream` connection to a secure `tls` connection.
View starttls.js
// Target API:
//
// var s = require('net').createStream(25, 'smtp.example.com');
// s.on('connect', function() {
// require('starttls')(s, options, function() {
// if (!s.authorized) {
// s.destroy();
// return;
// }
//
@TooTallNate
TooTallNate / gist:865250
Created Mar 11, 2011
Cannot extend global prototypes in the REPL...
View gist:865250
nrajlich@nathan-HP-Mini-311:~$ cat repl-fail.js
global.Object.prototype.test = true;
nrajlich@nathan-HP-Mini-311:~$ cat repl-test.js
require('./repl-fail');
console.log(typeof {}.test);
nrajlich@nathan-HP-Mini-311:~$ node repl-test.js
boolean
@TooTallNate
TooTallNate / gist:906665
Created Apr 6, 2011
Output of "sysctl -a hw" on my iPhone 4.
View gist:906665
hw.ncpu: 1
hw.byteorder: 1234
hw.memsize: 527433728
hw.activecpu: 1
hw.physicalcpu: 1
hw.physicalcpu_max: 1
hw.logicalcpu: 1
hw.logicalcpu_max: 1
hw.cputype: 12
hw.cpusubtype: 9
@TooTallNate
TooTallNate / iOS-Vibrate.c
Created Apr 7, 2011
A "Hello World" to doing a vibration in pure C, on iOS.
View iOS-Vibrate.c
// To compile:
// gcc -framework AudioToolbox iOS-Vibrate.c -o iOS-Vibrate
#include <AudioToolbox/AudioServices.h>
int main() {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
return 0;
}
@TooTallNate
TooTallNate / gist:913195
Created Apr 11, 2011
Trying to make a 'wscript' file that compiles a c file with one set of cxxflags, and a cpp with a different set of cxxflags...
View gist:913195
def set_options(opt):
opt.tool_options("compiler_cxx")
def configure(conf):
conf.check_tool("compiler_cxx")
conf.check_tool("node_addon")
def build(bld):
obj = bld.new_task_gen("cxx")
@TooTallNate
TooTallNate / crc.js
Created Apr 28, 2011
Modbus Serial RTU CRC Algorithm
View crc.js
var data;
process.stdin.on('data', function(chunk) {
data = chunk
});
process.stdin.on('end', function() {
console.log(data);
var givenCrc = data.slice(data.length-2);
givenCrc = (data[1] << 7 | data[0]);
console.log(givenCrc);
View 0001-Make-sure-ARCH-get-s-defined-with-the-CMake-build-sy.patch
From 89b1d1dbada903a97602a2c64ca9bfde1e0534af Mon Sep 17 00:00:00 2001
From: Nathan Rajlich <nathan@tootallnate.net>
Date: Tue, 3 May 2011 08:51:53 -0700
Subject: [PATCH] Make sure 'ARCH' get's defined with the CMake build system.
---
cmake/configure.cmake | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/cmake/configure.cmake b/cmake/configure.cmake