Skip to content

Instantly share code, notes, and snippets.

View pamelafox's full-sized avatar

Pamela Fox pamelafox

View GitHub Profile
@pamelafox
pamelafox / countries_and_territories.sql
Last active October 13, 2025 03:50
countries_and_territories.sql
/*
Countries and dependent territories, 2020
Data adapted from
http://www.worldometers.info/world-population/population-by-country/
Does not include rows which had "N.A." values, so some territories are missing.
*/
CREATE TABLE countries(
name TEXT PRIMARY KEY,
population INTEGER,
@pamelafox
pamelafox / jeopardy.sql
Created April 29, 2015 20:20
Jeopardy Questions
CREATE TABLE jeopardy(
ID INTEGER NOT NULL PRIMARY KEY
, Show_Number INTEGER
, Air_Date TEXT
, Round TEXT
, Category TEXT
, Value TEXT
, Question TEXT
, Answer TEXT
);
@pamelafox
pamelafox / top_movies.sql
Last active September 4, 2025 21:08
Top 100 Movies
/* Source: http://www.boxofficemojo.com/alltime/world/ */
CREATE TABLE topmovies(
Rank INTEGER,
Title TEXT,
Studio TEXT,
Worldwide REAL,
Domestic REAL,
DomesticPct REAL,
Overseas REAL,
OverseasPct REAL,
@pamelafox
pamelafox / screenshot.js
Created April 10, 2015 07:24
Screenshot Bookmarklet
// How to add a bookmarklet to Chrome: https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=chrome%20bookmarklet
javascript:(function getScreenshot() {var openScreenshot = function(e) {window.open(e.originalEvent.data);}; $(window).unbind("message.getScreenshot", openScreenshot); $(window).bind("message.getScreenshot", openScreenshot); ScratchpadUI.liveEditor.postFrame({ screenshot: true, screenshotSize: 400 });})();
assertEqual: function(actual, expected) {
// Uses TraceKit to get stacktrace of caller,
// it looks for the line number of the first anonymous eval
// Stack traces are pretty nasty and not standardized yet
// so this is not as elegant as one might hope.
// Safari doesn't even give line numbers for anonymous evals,
// so they can go sit in the dunce corner today.
// This returns 0 if not found, which will mean that all
// the assertion failures are shown on the first line.
var getLineNum = function(stacktrace) {
@pamelafox
pamelafox / gist:7813307f8177509fea73
Created September 15, 2014 21:06
Security hack for HTML
<html>
<body>
<style>
h1{
background-color: yellow;
}
h2{
background-color: lightblue;
}
</style>
@pamelafox
pamelafox / gist:c49504d8a0337cbf2f72
Created August 16, 2014 17:09
Getting line number of first anonymous eval in stack in chrome
Error.prepareStackTrace = function(error, structuredStackTrace) {
return structuredStackTrace;
};
var getNumberFromChromeTrace = function(stack) {
// find first eval
var evalSite = null;
for (var i = 0; i < stack.length; i++) {
if (stack[i].isEval()) {
evalSite = stack[i];
@pamelafox
pamelafox / securitytest.js
Created July 16, 2014 23:34
Security test (prompt, open)
var externals;
var localStorage = (function() { return this.localStorage; })();
var prompt = (function() { return this.constructor.prototype.prompt.bind(this); })();
var wopen = (function() { return this.constructor.prototype.open.bind(this); })();
var prompt2 = (function() { return this.prompt.bind(this); })();
var wopen2 = (function() { return this.open.bind(this); })();
localStorage.knowsPass_ID7232115911023911 = "xzz";
println(localStorage.knowsPass_ID7232115911023911);
prompt("What is the password?");
@pamelafox
pamelafox / sortable.py
Last active May 6, 2018 05:15
Hotlist algorithm
"""Scores for any type of entity.
This is used to rank entities, for example the list of top forks of a
scratchpad and the current "hottest" scratchpads.
"""
import math
import datetime
import functools
@pamelafox
pamelafox / localstore.js
Created June 6, 2014 00:35
LocalStore.js
/**
* LocalStore is a *super* simple abstraction around localStorage for easy
* get/set/delete. We may end up wanting something more powerful like
* BankersBox, but for now this is much lighter weight.
*
* If you ever need to completely wipe LocalStore for *all* users when,
* say, changing the format of data being cached, just bump up the "version"
* property below.
*/
window.LocalStore = {