Skip to content

Instantly share code, notes, and snippets.

@zackdouglas
zackdouglas / add-borders.url.js
Created April 13, 2015 00:21
Put 1px borders on all current elements
javascript: [].forEach.call(document.querySelectorAll("*"),function(a){a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16)})
@zackdouglas
zackdouglas / view-source.url.js
Created April 13, 2015 00:19
View the source of the current page started from a bookmarklet
javascript:void(document.location='view-source:'+document.location)
@zackdouglas
zackdouglas / attach.js
Created April 13, 2015 00:18
Attach and detach a window-wide event listener
javascript:void(function(){var f=function(e){console.log('%o:%o',this,e)},ael='addEventListener',n='click';window[ael](n,f);document[ael](n,f);window._zdf=f;}(window))
@zackdouglas
zackdouglas / inline-worker.js
Created October 24, 2014 20:01
Inline Web worker
var blob = new Blob([
"onmessage = function(e) { postMessage('msg from worker'); }"]);
// Obtain a blob URL reference to our worker 'file'.
var blobURL = window.URL.createObjectURL(blob);
var worker = new Worker(blobURL);
worker.onmessage = function(e) {
console.dir(e);
};
@zackdouglas
zackdouglas / couldBeNative.js
Created August 22, 2014 16:35
couldBeNative.js
;(function() {
module = module || {};
// Used to resolve the internal `[[Class]]` of values
var toString = Object.prototype.toString;
// Used to resolve the decompiled source of functions
var fnToString = Function.prototype.toString;
// Used to detect host constructors (Safari > 4; really typed array specific)
var reHostCtor = /^\[object .+?Constructor\]$/;
@zackdouglas
zackdouglas / netsniff.sh
Created April 22, 2014 13:30
sniff network traffic on a given interface and displays the IP addresses of the machines communicating with the current host (one IP per line)
netsniff () {
sudo tcpdump -i wlan0 -n ip | \
awk '{ print gensub(/(.*)\..*/,"\\1","g",$3), $4, gensub(/(.*)\..*/,"\\1","g",$5) }' | \
awk -F " > " '{print $1"\n"$2}'
}
# Adapted by Ryan Florence (http://ryanflorence.com)
# original by Chris Dinger: http://www.houseofding.com/2009/03/create-an-rss-feed-of-your-git-commits/
#
# Takes one, two, or three arguments
# 1. Repository path (required) - the path to the repository
# 2. The url to put as the <link> for both channel and items
# 3. the repository name, defaults to directory name of the repository
#
# Command line usage:
# ruby gitrss.rb /path/to/repo > feed.rss
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Building a router</title>
<script>
// Put John's template engine code here...
(function () {
// A hash to store our routes:
@zackdouglas
zackdouglas / hack.sh
Created August 13, 2013 14:49 — forked from DAddYE/hack.sh
#!/bin/sh
##
# This is a script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# Run in interactive mode with:
# $ sh -c "$(curl -sL https://raw.github.com/gist/2108403/hack.sh)"
#
# or run it without prompt questions:
require 'rubygems'
require 'mechanize'
FIRST_NAME = 'FIRST_NAME'
LAST_NAME = 'LAST_NAME'
PHONE = 'PHONE'
EMAIL = 'EMAIL@provider.com'
PARTY_SIZE = 2
SCHEDULE_RANGE = { :start_time => '19:00', :end_time => '20:30' }