Skip to content

Instantly share code, notes, and snippets.

View dethe's full-sized avatar

Dethe Elza dethe

View GitHub Profile
@dethe
dethe / gist:7224448
Created October 29, 2013 23:17
Rough heuristic for determining whether a site was loaded by the user (first party vs. third party)
Heuristic for determining first party-ness
1. Does the request have a referrer?
2. Ignore requests that cannot be associated with a window (tab)
3. Is this request part of resolving the page (not Ajax)?
4. Are we able to resolve a host domain for referrer and tab URIs?
5. Are they the same?
6. Are they *not* 'about:blank'?
7. Ignore requests that come from within the add-on
8. Ignore requests that don't have a valid target or source
@dethe
dethe / gist:6945741
Created October 12, 2013 04:11
Mozilla limerick
A browser that came from Mozilla
Let me download so fast it was killa
With standards so fine
The whole web felt like mine
So I built some apps with no filla
var global = new Global();
(function(){
var local = new Local();
local.canvas = document.createElement("canvas");
local.canvas.setAttribute("width", global.stage_width);
local.canvas.setAttribute("height", global.stage_height);
global.stage.appendChild(local.canvas);
local.ctx = local.canvas.getContext("2d");
local.ctx.textAlign = "center";
var main = function(){
@dethe
dethe / square.html
Created September 1, 2013 19:40
HTML Blue Square
<html>
<style>
.square{
width: 50px;
height: 50px;
background-color: blue;
</style>
<div class="square"></div>
</html>
{
"title": "Blacklight Worms",
"description": "Nice, but simple, use of sprites",
"date": 1371022449674,
"waterbearVersion": "2.0",
"blocks": [
{
"blocktype": "context",
"group": "scripts_workspace",
"id": "c7540554-a5d3-4dbf-bc62-f948b68b0d65",
@dethe
dethe / random_circles..js
Last active December 18, 2015 07:28
New examples for Waterbear
local.count_201 = 0;
(function() {
setInterval(function() {
local.count_201++;
var point_202 = {
x: randint(0, global.stage_width),
y: randint(0, global.stage_height)
};
var radius_202 = 30;
var color_202 = "rgb(" + randint(0, 255) + "," + randint(0, 255) + "," + randint(0, 255) + ")";
@dethe
dethe / coldata3.js
Last active December 14, 2015 22:09
var visualizations = {};
var data = {
"format": "CollusionSaveFile",
"version": "1.0",
"token": "{0ccd56d1-2f59-2142-8f72-e4d12dd64769}",
"connections": [
[
"lanistaads.com",
"rubiconproject.com",
1362156908018,
@dethe
dethe / trails.js
Last active December 10, 2015 05:08
Slightly more complex Waterbear example using the rectangle sprites
var global = new Global();
(function(){
var local = new Local();
local.canvas = document.createElement("canvas");
local.canvas.setAttribute("width", global.stage_width);
local.canvas.setAttribute("height", global.stage_height);
global.stage.appendChild(local.canvas);
local.ctx = local.canvas.getContext("2d");
local.ctx.textAlign = "center";
var main = function(){
@dethe
dethe / random_circles.js
Last active October 13, 2015 04:57
Simplest example of a Waterbear script (for Javascript canvas)
local.count_1 = 0;
(function() {
setInterval(function() {
local.count_1++;
var point_2 = {
x: randint(0, global.stage_width),
y: randint(0, global.stage_height)
};
var radius_2 = randint(20, 50);
var color_2 = "rgb(" + randint(0, 255) + "," + randint(0, 255) + "," + randint(0, 255) + ")";
@dethe
dethe / blacklightworms.pjs
Created September 11, 2012 19:56
Example code to test processing.js embeddeding in Tumblr
int number = 15;
float[] x = new float[number];
float[] y = new float[number];
float[] r = new float[number];
float[] theta = new float[number];
float[] offset = new float[number];
int minRadius = 30;
int maxRadius = 60;
void setup(){