Skip to content

Instantly share code, notes, and snippets.

void
test_PrototypeInScript()
{
HandleScope handle_scope;
Persistent<Context> context = Context::New();
Context::Scope context_scope(context);
Local<Object> obj;
Local<FunctionTemplate> obj_tmpl = FunctionTemplate::New();
@zpao
zpao / README.md
Created June 6, 2011 17:56
autoconf 2.13 homebrew formula

Install

  1. install homebrew
  2. place autoconf.rb into Formula folder: /usr/local/Library/Formula/
  3. run brew install autoconf
@zpao
zpao / run-this.js
Created June 10, 2011 23:27
Simple Window + Tab Stats
/* Run this in your error console */
var wc=0, tc=0, tgc=0;
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/DownloadUtils.jsm");
var wm = Services.wm;
var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
var e = wm.getEnumerator("navigator:browser");
var uc = { };
while (e.hasMoreElements()) {
@zpao
zpao / UUIDgen.pl
Created October 28, 2011 05:37
a hubot plugin using coffeescript vs a firebot plugin using perl
################################
# UUIDGen Module #
################################
# "uuidgen" should be installed on the path somewhere.
# you can get the source of uuidgen from CVS, see:
# http://lxr.mozilla.org/mozilla/source/webtools/mozbot/uuidgen/
package BotModules::UUIDGen;
use vars qw(@ISA);
diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp
index afa2125..2afdbb8 100644
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -7230,7 +7230,6 @@ dumpValue(const Value &v)
fprintf(stderr, "false");
} else if (v.isMagic()) {
fprintf(stderr, "<invalid");
-#ifdef DEBUG
switch (v.whyMagic()) {
function datediff(aDate1, aDate2) {
var diff = Math.abs(aDate2 - aDate1);
var milliseconds = diff % 1000;
var seconds = Math.floor(diff / 1000 % 60);
var minutes = Math.floor(diff / (1000 * 60) % 60);
var hours = Math.floor(diff / (1000 * 60 * 60) % 24);
var days = Math.floor(diff / (1000 * 60 * 60 * 24) % 365);
return [
@zpao
zpao / gist:1665805
Created January 23, 2012 22:13
patch to get v8monkey building (but not working)
diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp
index afa2125..2afdbb8 100644
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -7230,7 +7230,6 @@ dumpValue(const Value &v)
fprintf(stderr, "false");
} else if (v.isMagic()) {
fprintf(stderr, "<invalid");
-#ifdef DEBUG
switch (v.whyMagic()) {
@zpao
zpao / ZAppDelegate.m
Created March 16, 2012 06:42
Xcode generates code with excellent whitespace...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.mainViewController = [[ZMainViewController alloc] initWithNibName:@"ZMainViewController_iPhone" bundle:nil];
} else {
self.mainViewController = [[ZMainViewController alloc] initWithNibName:@"ZMainViewController_iPad" bundle:nil];
}
self.window.rootViewController = self.mainViewController;
@zpao
zpao / freeze.js
Created May 27, 2012 00:11
Exploring prototypes & Object.freeze
function makeObj(freeze) {
var o = {
foo: "bar",
doit: function() {
console.log(this.foo);
}
}
if (freeze)
Object.freeze(o);
@zpao
zpao / t2j.coffee
Created May 27, 2012 00:55
Script I wrote to import my Tumblr to Jekyll
#!/usr/bin/env coffee
request = require "request"
fs = require "fs"
TARGET_DIR = "./_posts"
PHOTO_SIZE = 1280
url = "http://blog.zpao.com/api/read?format=json&filter=none&num=50"