Skip to content

Instantly share code, notes, and snippets.

@eendeego
eendeego / README.md
Created November 14, 2012 17:44
Profiling node.js apps with Ben Noordhuis heapdump

This instructions allow you to take periodical heapdumps.

To use in your project, first install heapdump, then add the following code to your app just after requiring 'fs'.

@eendeego
eendeego / bindings-cheat-sheet.md
Created November 28, 2012 10:26
Node/V8 bindings cheat sheet
@eendeego
eendeego / build-node.sh
Created November 28, 2012 11:29
Custom build node
#!/usr/bin/env bash
export NODE_VER=0.8.15
cd ~
rm -rf ~/work/node-build/node-$NODE_VER;mkdir -p ~/work/node-build && cd ~/work/node-build
rm -rf ~/opt/node-$NODE_VER;mkdir -p ~/opt/node-$NODE_VER
[[ -f node-v$NODE_VER.tar.gz ]] || \
curl -O http://nodejs.org/dist/v$NODE_VER/node-v$NODE_VER.tar.gz
@eendeego
eendeego / gist:4341562
Created December 19, 2012 23:20
share mac directory with rpi via nfs
ssh <sudoer>@<server>
sudo su -
mkdir -p <share-starting-at-/>
cat > /etc/exports <<EOF
# /path options clients
<share-starting-at-/> -network 192.168.1.0 -mask 255.255.255.0
EOF
mkdir hadoop
cd hadoop
wget http://mirrors.fe.up.pt/pub/apache/hadoop/common/hadoop-1.1.1/hadoop-1.1.1-bin.tar.gz
tar zxvf hadoop-1.1.1-bin.tar.gz
mkdir conf
cp hadoop-1.1.1/conf/* conf/
export HADOOP_CONF_DIR=$PWD/conf
@eendeego
eendeego / gist:4537826
Last active December 11, 2015 03:28
Clean way to access node's typed arrays.
template<class C> class TypedArrayWrapper {
private:
Local<Object> array;
Handle<Object> buffer;
int offset;
public:
TypedArrayWrapper(const Local<Value>& arg) :
array(arg->ToObject()),
buffer(array->Get(String::New("buffer"))->ToObject()),
offset(array->Get(String::New("byteOffset"))->Int32Value()) {
@eendeego
eendeego / v8.05.log.processed
Created January 15, 2013 14:37
Profiling do Canvas
Statistical profiling result from v8.log, (106127 ticks, 18327 unaccounted, 0 excluded).
[Unknown]:
ticks total nonlib name
18327 17.3%
[Shared libraries]:
ticks total nonlib name
31348 29.5% 0.0% /home/pi/opt/v8-99a2d28-shared/lib/libv8.so
200 0.2% 0.0% /lib/arm-linux-gnueabihf/ld-2.13.so
@eendeego
eendeego / launch.sh
Created February 5, 2013 21:39
Launch TopCoder Arena on OS X with Java 7/8
#!/bin/bash
cd `dirname $0`
curl\
--remote-name \
--remote-header-name\
http://www.topcoder.com/contest/arena/ContestAppletProd.jnlp
JAVAWS="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/javaws"
#!/usr/bin/env node --trace_gc
# See also "Timers" in
# http://coding.smashingmagazine.com/2012/11/05/writing-fast-memory-efficient-javascript/
'use strict';
process.on('uncaughtException', function (err) {
console.log('Caught exception: ' + err);
});
@eendeego
eendeego / nokia6100.ino
Last active December 15, 2015 20:28
arduino vs nokia 6100 test code
#include <ColorLCDShield.h>
#define SHIFT_TO_RED 8
#define SHIFT_TO_GREEN 4
#define SHIFT_TO_BLUE 0
#define BACKGROUND BLACK // room for growth, adjust the background color according to daylight
#define RGB(r,g,b) (((b) << SHIFT_TO_BLUE) + ((g) << SHIFT_TO_GREEN) + ((r) << SHIFT_TO_RED))
LCDShield lcd;