Skip to content

Instantly share code, notes, and snippets.

View leibovic's full-sized avatar

Margaret Leibovic leibovic

  • League
  • Ottawa, ON
  • 18:14 (UTC -04:00)
View GitHub Profile
@leibovic
leibovic / iconscrape.py
Created July 26, 2011 18:51
A script to look for icons specified in link tags with rel="icon" and the sizes attribute, or with rel="apple-touch-icon"
#! /usr/bin/env python
import csv
import urllib2
import sgmllib
class LinkParser(sgmllib.SGMLParser):
def parse(self, s):
self.feed(s)
self.close()
@leibovic
leibovic / dominant-color.js
Created June 9, 2011 16:27
Dominant Color
function getDominantColor(aImg) {
let canvas = document.createElement("canvas");
canvas.height = aImg.height;
canvas.width = aImg.width;
let context = canvas.getContext("2d");
context.drawImage(aImg, 0, 0);
// keep track of how many times a color appears in the image
let colorCount = {};
SRCDIR=mozilla-central
MOZCONFIG=$(SRCDIR)/.mozconfig-droid
OBJDIR=$(SRCDIR)/obj-android
MAKE=make -s -j8
embedding:
$(MAKE) -C $(OBJDIR)/embedding
mobile:
$(MAKE) -C $(OBJDIR)/mobile/android
@leibovic
leibovic / gist:2305880
Created April 4, 2012 21:35 — forked from rnewman/gist:2305471
Start of a query
Due to limitations of SQLite, we need to make a temp table for this:
CREATE TEMP TABLE duped_urls AS
SELECT url, SUM(visits) AS total, MAX(modified) AS latest, MAX(_id) AS winner
FROM history
GROUP BY url
HAVING count(url) > 1;
UPDATE history
SET visits = (SELECT total FROM duped_urls WHERE duped_urls.url=history.url),
@leibovic
leibovic / data-uri.sh
Created September 28, 2015 21:58
png to data URI
echo -n `cat file.png` | base64 > output.txt
openssl base64 < file.png | tr -d '\n' > output.txt
cat file.png | openssl base64 | tr -d '\n' > output.txt
openssl base64 -in file.png -out output.txt
@leibovic
leibovic / add-logins.js
Created September 24, 2015 18:06
Adds fake logins to yout Firefox login manager
/*
* This is a JavaScript Scratchpad.
*
* Enter some JavaScript, then Right Click or choose from the Execute Menu:
* 1. Run to evaluate the selected text (Cmd-R),
* 2. Inspect to bring up an Object Inspector on the result (Cmd-I), or,
* 3. Display to insert the result in a comment after the selection. (Cmd-L)
*/
function addFakeLogins(window) {
@leibovic
leibovic / scratchpad.js
Created June 11, 2015 23:06
Replaces the signed ABP extension file in the profile directory with a slightly modified version
let fileName = "{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}.xpi";
// Copy new add-on file from sdcard to profile extensions directory
let newFile = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsILocalFile);
newFile.initWithPath("/sdcard/" + fileName);
let extDir = FileUtils.getFile("ProfD", ["extensions"]);
newFile.copyTo(extDir, fileName);
console.log("moved file from sdcard to extensions directory");
# HG changeset patch
# User Nick Alexander <nalexander@mozilla.com>
# Date 1431118818 25200
# Fri May 08 14:00:18 2015 -0700
# Node ID 5645e1d9cbf3f76429dba78e25d8121327cbbb2a
# Parent 0406efcbb88be90a7e2163087f82dc89921b9b48
No bug - Add leakcanary to base Gradle project.
diff --git a/mobile/android/base/GeckoApplication.java b/mobile/android/base/GeckoApplication.java
--- a/mobile/android/base/GeckoApplication.java
@leibovic
leibovic / task.js
Last active August 29, 2015 14:15
Web compatible version of Task.jsm
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80 filetype=javascript: */
/* 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/. */
"use strict";
/**
* This module implements a subset of "Task.js" <http://taskjs.org/>.
@leibovic
leibovic / pngcrush.sh
Created November 5, 2014 22:18
pngcrush all changed files in the topmost hg commit
#!/bin/bash
# pngcrushes any changed files in the top-most patch
files=`hg status -n --rev .^`
for f in $files
do
echo $f
pngcrush $f $f.new
mv $f.new $f