Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@xabolcs
xabolcs / SCGIRequest.java
Last active July 25, 2017 22:54
Java SCGI request
import org.apache.commons.io.input.ReaderInputStream;
import org.apache.commons.lang.StringUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.LinkedHashMap;
# Adblock script for OpenWRT
# (c) 2014 by Jan Holthuis
#
# This is an adblocker script for OpenWRT. Simply run this script as a
# daily cronjob on your OpenWRT-router. This works since OpenWRT
# revision 39312 [1] and does not manipulate any files in /etc/.
# Instead, this adds the adblock serverlist as a separate file
# to /tmp/dnsmasq.d/. It also checks the file with grep to make sure
# that it doesn't contain malicious commands.
#
@xabolcs
xabolcs / collectionStatsLogger.js
Last active August 29, 2015 13:56
MemChaser analysis for Issue #184
function csLogger (subject, topic, data) { console.log (topic, data); }
Services.obs.addObserver(csLogger, "garbage-collection-statistics", false);
Services.obs.addObserver(csLogger, "cycle-collection-statistics", false);
@xabolcs
xabolcs / gist:4115084
Created November 20, 2012 00:16
Dumb fix for mozmill-automation 'EnduranceTestrun'
diff --git a/mozmill_automation/testrun.py b/mozmill_automation/testrun.py
--- a/mozmill_automation/testrun.py
+++ b/mozmill_automation/testrun.py
@@ -468,6 +468,34 @@
""" Execute the endurance tests in sequence. """
self.endurance_results = []
+
+ # instantiate handlers
+ logger = mozmill.logger.LoggerListener(log_file=self.options.logfile,
@xabolcs
xabolcs / toolkit.js
Created October 27, 2012 17:31
Moving forward from nightly.variables.toolkit == "cairo"
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo); gfxInfo.getInfo().toSource();
/**
* Example output:
* ({AzureCanvasBackend:"cairo", AzureFallbackCanvasBackend:"none", AzureContentBackend:"none"})
*
* Or:
* Error: gfxInfo.getInfo is not a function
*
* Or even:
@xabolcs
xabolcs / brodyFile2DataURL.js
Created August 28, 2012 14:33
Converting images to base64
/**
* To get a base64 encoded data uri from a local file
*
* @originalauthor brody at MozillaZine
* @see http://forums.mozillazine.org/viewtopic.php?p=5091285#p5091285
*/
brodyFile2DataURL = {
getFileFromURLSpec: function(aURL) {
var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
var fph = ios.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler);
@xabolcs
xabolcs / installedLangpacks.js
Created August 24, 2012 07:31
NTT Issue #60: Langpack auto updater for daily builds
Components.utils.import("resource:///modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource:///modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AddonManager", "resource:///modules/AddonManager.jsm");
AddonManager.getAddonsByTypes(["locale"] , function (aAddons) {
aAddons.forEach(function(aAddon){
Services.console.logStringMessage(aAddon.name + " ("+ aAddon.id +") is " + (aAddon.isCompatible ? "compatible" : "not compatible") );
});
});
@xabolcs
xabolcs / bootstrap.js
Created February 18, 2012 06:52
Test bootstrap.js for RestartlessMenuItems.js at https://github.com/protz/thunderbird-stdlib/pull/4/files
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
Components.utils.import('resource://gre/modules/Services.jsm');
function startup(aData, aReason) {
var fileuri = Services.io.newFileURI(aData.installPath);
if (!aData.installPath.isDirectory())
@xabolcs
xabolcs / prototypes.js
Created June 24, 2011 14:51
BarTabWebProgressListener.onStateChange vs browser.webNavigation._pauseLoadURI is not a function
/*
* Progress listener that stops the loading of tabs that are opened in
* the background and whose contents is loaded by C++ code. This
* occurs for instance when the 'browser.tabs.loadDivertedInBackground'
* preference is enabled (because links are always opened by docshell code).
*/
function BarTabWebProgressListener () {}
BarTabWebProgressListener.prototype = {
...
/*** nsIWebProgressListener ***/
@xabolcs
xabolcs / prototypes.js
Created April 26, 2011 21:52
passed through setCurrentURI in BarTabWebNavigation
...
/*** These methods and properties are simply passed through. ***/
setCurrentURI: function (aURI) {
return this._original.setCurrentURI(aURI);
},
goBack: function () {
return this._original.goBack();
},
...