Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# Based on Is the Tree Green? <http://isthetreegreen.com>
# Original Code & Concept by Justin Dolske <[email protected]>
# Ported to Python by Paul O'Shannessy <[email protected]>
import getopt, sys
from urllib import urlopen
CmdUtils.CreateCommand({
name: "tr.im",
preview: "Trims URLs using the tr.im service",
homepage: "http://tr.im/",
help: "Trims the selected URL.",
takes: {"url": noun_arb_text},
modifiers: {name: noun_arb_text, password: noun_arb_text},
execute: function(urlToTrim, mods) {
var url = "http://tr.im/api/trim_url.json";
var params = Array();
function test() {
waitForExplicitFinish();
// the value we expect to be on the clipboard
const EXPECTED_VAL = "foo";
// function that will setup the clipboard
function setup() {
Cc["@mozilla.org/widget/clipboardhelper;1"].
getService(Ci.nsIClipboardHelper).
/*
* Polls the clipboard waiting for the expected value. A known value different than
* the expected value is put on the clipboard first (and also polled for) so we
* can be sure the value we get isn't just the expected value because it was already
* on the clipboard. This only uses the global clipboard and only for text/unicode
* values.
*
* @param aExpectedVal
* The string value that is expected to be on the clipboard
* @param aSetupFn
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++) {
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({
git diff `git merge-base HEAD master`
/* 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 {
/* 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();
@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"