Skip to content

Instantly share code, notes, and snippets.

View leibovic's full-sized avatar

Margaret Leibovic leibovic

  • League
  • Ottawa, ON
  • 19:13 (UTC -04:00)
View GitHub Profile
@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 / 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 = {};