Skip to content

Instantly share code, notes, and snippets.

@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);
@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 / 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
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 / assignment_array.js
Created February 26, 2011 00:45
Multiple (destructuring) assignment in JS
var arr = ["yea, yea", "we knew this worked"];
var [a, b] = arr;
// a == "yea, yea"
// b == "we knew this worked"
/* Run this from your error console. WARNING: removes tabs from their existing groups! */
var Cc = Components.classes;
var Ci = Components.interfaces;
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
var winEnum = wm.getEnumerator("navigator:browser");
while (winEnum.hasMoreElements()) {
var win = winEnum.getNext();
win.TabView._initFrame(function() {
var contentWindow = win.TabView._window;
contentWindow.UI.reset();
/* Run this from your error console */
var Cc = Components.classes;
var Ci = Components.interfaces;
var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
var winEnum = wm.getEnumerator("navigator:browser");
while (winEnum.hasMoreElements()) {
var win = winEnum.getNext();
["tabview-group", "tabview-groups", "tabview-ui", "tabview-visibility"].forEach(function(v) {
try {
git diff `git merge-base HEAD master`
var latestTweetRequest = Request({
url: "http://api.twitter.com/1/statuses/public_timeline.json",
onComplete: function () {
var tweet = this.response.json[0];
console.log("User: " + tweet.user.screen_name);
console.log("Tweet: " + tweet.text);
}
});
// Be a good consumer and check for rate limiting before doing more.
Request({
Array.prototype.oldPush = Array.prototype.push;
Array.prototype.push = function(val) {
if (this.length > 3)
alert("wtfbbq - " + this);
this.oldPush(val);
};
var foo = [];
var bar = [1,2,3,4,5];
for (var i = 0; i < bar.length; i++) {