Skip to content

Instantly share code, notes, and snippets.

@hallvors
hallvors / minicss.js
Created December 6, 2013 11:14
A method that tries to remove CSS rules that do not apply to anything in the current page, aids in minimising test cases
(function minimizeCSS(){
var s = document.styleSheets[0].cssRules;
var j=s.length-1, ar=[];
try{
for(;j>=0;j--){
if(document.querySelectorAll(s[j].selectorText).length>0)ar.push(s[j].cssText);
}
}catch(e){
console.log('error for style #'+j)
}
@hallvors
hallvors / sumo-975037.htm
Created December 12, 2013 14:19
Test case for SUMO issue 975037
<!DOCTYPE html>
<html>
<head><title>document.write and the back button</title></head>
<body>
<p>FAILED (not ran)</p>
<iframe src="./"></iframe>
<script>
// there is something odd with document.write() and IFRAME
// one immediately, inline
writeIframe('1st time - inline');
@hallvors
hallvors / marionette-spoof.py
Last active January 3, 2016 08:28
How to spoof user-agent in Firefox from a Python script using the Marionette API
from marionette import Marionette
def set_mozilla_pref(marionette_instance, name, value):
marionette_instance.set_context(marionette_instance.CONTEXT_CHROME)
js = """
var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
str.data = "%s";
pref.setComplexValue("%s", Components.interfaces.nsISupportsString, str)
""" % (value, name)
@hallvors
hallvors / yui-lightbox.js
Created January 22, 2014 09:07
some of the code that runs the lightbox feature on flickr.com
function k(aC, aG, aJ) {
var aI, aD, aO, aM, aP, aF = true, aL, Y;
if (aC) {
aI = K(aC)
} else {
return
}
var aN = at().width;
if (aC.get("needs_interstitial")) {
aF = true
var btn = document.getElementById("copy-button");
btn.addEventListener("click", clickHandler, false);
function clickHandler(e) {
document.exeCommand('copy');
}
http://www.veoh.com/
http://screen.yahoo.com/
http://blip.tv/
http://www.metacafe.com/
http://www.ovguide.com/
http://www.ndtv.com/video/
http://video.pbs.org/
http://www.microsoft.com/showcase/
http://www.youtube.com/
http://www.eonline.com/news/watch_with_kristin
@hallvors
hallvors / br-sites.txt
Last active August 29, 2015 13:57
Sites considered popular or important in Brazil
google.com.br
uol.com.br
globo.com
mercadolivre.com.br
itau.com.br
hao123.com
abril.com.br
terra.com.br
ig.com.br
caixa.gov.br
@hallvors
hallvors / mx-sites.txt
Last active August 29, 2015 13:57
Sites considered popular or important in Mexico
mercadolibre.com.mx
taringa.net
unam.mx
sat.gob.mx
segundamano.mx
eluniversal.com.mx
occ.com.mx
maps.google.com.mx
banamex.com.mx
musica.com
@hallvors
hallvors / bangladesh-sites.txt
Created March 25, 2014 13:56
Sites considered popular or important in Bangladesh
google.com.bd
prothom-alo.com
bdnews24.com
banglanews24.com
espncricinfo.com
kalerkantho.com
banglamail24.com
bdjobs.com
priyo.com
bikroy.com
#!/bin/bash
DATE=`date +%Y%m%d`
ALEXA_URL=http://www.alexa.com/topsites/countries%3B
COUNTRY_CODE=$1
OUTPUT_FILE=ALEXA_${COUNTRY_CODE}-${DATE}.txt
echo "Downloading Alexa top site data for $COUNTRY_CODE"