Skip to content

Instantly share code, notes, and snippets.

View polm's full-sized avatar

Paul O'Leary McCann polm

View GitHub Profile
@polm
polm / gist:1072271
Created July 8, 2011 17:02
Selenium blows up with innerHTML and unicode
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Firefox()
driver.get("http://dampfkraft.com/emdash.html")
print driver.find_element_by_tag_name("p").get_attribute("innerHTML")
/* Inspired by Lee Byron's test data generator. */
function stream_layers(n, m, o) {
if (arguments.length < 3) o = 0;
function bump(a) {
var x = 1 / (.1 + Math.random()),
y = 2 * Math.random() - .5,
z = 10 / (.1 + Math.random());
for (var i = 0; i < m; i++) {
var w = (i / m - y) * z;
a[i] += x * Math.exp(-w * w);
@polm
polm / README.md
Created November 11, 2011 09:42 — forked from anonymous/gist.html
World Generator with d3

World Generator

This code creates a Voronoi Diagram of a low-resolution space, generating an approximation of regional divisions of an overworld map typical of the first Legend of Zelda or Link's Awakening. The white squares are randomly generated "centers".

http://en.wikipedia.org/wiki/Voronoi_diagram

@polm
polm / vimium.conf
Created April 4, 2012 03:17
Vimium settings
unmap J
map J nextTab
unmap K
map K previousTab
unmap d
map d removeTab
unmap x
unmap X
unmap u
map u restoreTab
@polm
polm / index.html
Created June 5, 2012 13:54
Count of Monte Cristo Character & Place Graph Rough
<html>
<title>Count of Monte Cristo Character Mentions</title>
<script src="http://d3js.org/d3.v2.js?2.8.1"></script>
<div id="viz"></div>
<script>
function doGraph(rows){
//scales
_ = require 'underscore'
r = Math.random
rr = (x) -> ~~(r() * x)
#How wide is the main hall?
hallwidth = (rr(3) * 2) + 4
#How tall can a room be?
#TODO make variable
@polm
polm / gist:4231626
Created December 7, 2012 08:00
tmux.conf
unbind C-b
set -g prefix `
set -g history-limit 10000
set -g status-bg blue
bind-key ` send-prefix
setw -g mode-keys vi
bind Escape copy-mode
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
@polm
polm / .Xdefaults
Created June 24, 2013 07:51
How to set up fonts for urxvt.
URxvt.background: black
URxvt.foreground: cyan
URxvt.scrollBar: false
URxvt.font: xft:ProFontWindows,\
xft:Bitstream Vera Sans Mono,\
xft:Ume Gothic O5,\
xft:Hiragino Maru Gothic Pro,\
xft:Osaka:style=Regular-Mono
URxvt.cursorBlink: true
#URxvt.font: xft:terminus
@polm
polm / deltos.coffee
Created August 22, 2013 23:41
Quick start of a static blog in Coffeescript.
#Load deps
fs = require('fs')
jsdom = require('jsdom').jsdom
yaml = require('js-yaml')
trans = require('transparency')
marked = require('marked')
_ = require('underscore')
#Load yaml
@polm
polm / gist:9085665
Created February 19, 2014 03:42
Ruby Syntax
'abc' + ['x', 'y', 'z'].join
# OK
'abc' + ['x', 'y', 'z'].join('')
# OK
'abc' + (['x', 'y', 'z'].join '')
# OK
'abc' + ['x', 'y', 'z'].join ''
# SyntaxError: unexpected tSTRING_BEG, expecting end-of-input
# ???