Skip to content

Instantly share code, notes, and snippets.

@grssam
grssam / unload.js
Created Feb 22, 2012
unload() function
View unload.js
/**
* Provide a way to remove / undo any changes made
* either at the unloading of the script/add-on in which this function is used
* or at the unloading of the container, if provided
*
* @param callback
* function to call when unloading of the script or container.
* This function should undo all the changes made.
* @param container
* Optional, the scope of the function.
@grssam
grssam / quotes
Created May 28, 2012 — forked from paulrouget/quotes
What robcee says
View quotes
<robcee> where's my hat?,
-------
<robcee> u r teh smartest,
-------
<robcee> I WILL TAKE THIS BULLET FOR YOU,
-------
* robcee swears violently
* robcee continues swearing,
-------
<robcee> hey everybody, forget email. Let's all go skiing. (toboggans also acceptable),
View restartCommand.js
/**
* Restart command
*
* @param number delay
* delay in seconds for the restart
* @param boolean disableFastload
* disabled loading from cache upon restart.
*
* Examples :
* >> restart
View sorttabs.js
/**
* Sort Tabs command
*
* @param number url_part
* a matching string to match the url of tabs.
* if this value is provided, the tabs not matching the criteria would not be shifted.
* @param boolean reverse
* true for reversing the direction of sort
*/
View s.js
/* ------- */
// Clean mess from previous session
Components.utils.import("resource:///modules/source-editor.jsm");
let nbox = gBrowser.getNotificationBox();
while (nbox.lastChild.id == "foobar-container" ||
nbox.lastChild.id == "foobar-splitter") {
nbox.removeChild(nbox.lastChild);
}
/* ------- */
// Build container
@grssam
grssam / read_file_per_line.js
Created Jul 26, 2012
Read a local file line by line
View read_file_per_line.js
let {Ci: interfaces, Cc: classes, Cu: utils} = Components;
let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
let file = ios.newURI(<file address>, null, null).QueryInterface(Ci.nsIFileURL).file;;
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Ci.nsIScriptableUnicodeConverter);
converter.charset = /* The character encoding you want, using UTF-8 here */ "UTF-8";
let fis = Cc["@mozilla.org/network/file-input-stream;1"]
.createInstance(Ci.nsIFileInputStream);
fis.init(file, -1, -1, 0);
let lis = fis.QueryInterface(Ci.nsILineInputStream);
@grssam
grssam / exit.js
Created Sep 6, 2012
Exit command for GCLI
View exit.js
Components.utils.import("resource:///modules/devtools/gcli.jsm");
gcli.addCommand({
name: "exit",
description: "Exits GCLI and closes the Developer Toolbar",
returnType: "null",
exec: function Exit(args, context) {
let window = context.environment.chromeDocument.defaultView;
let document = window.document;
View copyScreenshot.js
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
let EXPORTED_SYMBOLS = [ ];
Cu.import("resource:///modules/devtools/gcli.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
View copyScreenshot.js
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
let EXPORTED_SYMBOLS = [ ];
Cu.import("resource:///modules/devtools/gcli.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
View test.diff
# HG changeset patch
# User Girish Sharma <scrapmachines@gmail.com>
# Date 1347637171 -19800
# Node ID da31829c11c69e85a392a4161f6167c6e2297f94
# Parent a97775b456cf873ca6f809e03ff62e02028e7fe0
[mq]: scratchpad
diff --git a/browser/devtools/webconsole/HUDService.jsm b/browser/devtools/webconsole/HUDService.jsm
--- a/browser/devtools/webconsole/HUDService.jsm
+++ b/browser/devtools/webconsole/HUDService.jsm