Skip to content

Instantly share code, notes, and snippets.

View indexzero's full-sized avatar
🌎
Always bet on Open Source

Charlie Robbins indexzero

🌎
Always bet on Open Source
View GitHub Profile
@indexzero
indexzero / index.html
Created April 17, 2019 08:00 — forked from jjgonecrypto/index.html
es6 proxy #jsbench #jsperf (http://jsbench.github.io/#531652a2edfa806a5014558bafe6eb0e) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>es6 proxy #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
//
// Create our type
//
function PreLoader() {
this._queue = [];
this._mime = {};
this._handlers = {};
this._loaded = [];
};
PreLoader.prototype.addFileType = function addFileType(extension,mime) {
question:
- https://github.com/winstonjs/winston/issues/1107
- https://github.com/winstonjs/winston/issues/1119
- https://github.com/winstonjs/winston/issues/1088
- https://github.com/winstonjs/winston/issues/1148
- https://github.com/winstonjs/winston/issues/1167
- https://github.com/winstonjs/winston/issues/1192
- https://github.com/winstonjs/winston/issues/1201
- https://github.com/winstonjs/winston/issues/1275
- https://github.com/winstonjs/winston/issues/1226
@indexzero
indexzero / cocoa-hello-world2.js
Created September 8, 2011 18:33 — forked from TooTallNate/cocoa-hello-world2.js
Creating a Cocoa GUI window with NodObjC, with a proper Menu, dock icon, and NSApplicationDelegate.
// This example adapted from Matt Gallagher's "Minimalist Cocoa Programming"
// blog article:
// http://cocoawithlove.com/2010/09/minimalist-cocoa-programming.html
var $ = require('NodObjC')
$.import('Cocoa')
var pool = $.NSAutoreleasePool('alloc')('init')
, app = $.NSApplication('sharedApplication')

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

build

Clone and build Node for analysis:

$ git clone https://github.com/joyent/node.git
$ cd node
$ export GYP_DEFINES="v8_enable_disassembler=1 v8_object_print=1"
$ export CXXFLAGS="-fno-omit-frame-pointer"
$ ./configure

So, to get something like /etc/rc.local you can use the custom SMF import facility. (See the source for more information about how this actually works.)

/opt is mounted out of zones/opt by default. You can create a directory /opt/custom/smf and populate it with SMF manifests. Any manifests you put in there will be imported by SmartOS when it boots. Below is an example SMF manifest that simply starts /opt/custom/bin/postboot, a self-explanatory shell script that you can use like /etc/rc.local.

Note that it would likely be better to customise and respin your own images, as putting a bunch of platform state in the zones pool undoes some of the benefits of the ramdisk platform architecture that SmartOS has.

Node Error Handling and Domains

"Occurrences in this domain are beyond the reach of exact prediction because of the variety of factors in operation, not because of any lack of order in nature." - Albert Einstein

"Master of my domain" - Larry David

Error handling in an asynchronous language works in a unique way and presents many challenges, some unexpected. This tutorial reviews the various error handling patterns available in node, and explains how domains can be used to improve it.

There are four main error handling patterns in node:

  • Error return value
@indexzero
indexzero / range-error-ftw.js
Created November 28, 2012 09:41 — forked from dherman/range-error-ftw.js
fun with JS arrays
var a = [];
a[Math.pow(2, 32) - 2] = "max index"; // highest non-expando indexed property
console.log(a.length === Math.pow(2, 32) - 1); // true
try {
a.push("whoa", "EVEN MOAR WHOA");
} catch (e) {
console.log(e instanceof RangeError); // true
}