Skip to content

Instantly share code, notes, and snippets.

View d-baker's full-sized avatar

Cadence Baker d-baker

View GitHub Profile
@d-baker
d-baker / pseudomarkov.py
Created November 3, 2015 12:58
word chainer made for nanogenmo 2014. not a markov chain.
import random
class PseudoMarkov():
def __init__(self):
self.associations = {}
# pass it the corpus filepath
def gen(self, filepath):
sentences = []
@d-baker
d-baker / onsubmit.md
Created February 4, 2015 11:25
notes to self re. the onsubmit attribute
  • don't forget the return: it's onsubmit="return someFunction()" not onsubmit="someFunction()"
  • if you are relying on an external javascript file to provide someFunction(), the function mustn't be wrapped in anything else. this means, no $(document).ready() or the like. as a result, the external script needs to go *just before the closing `
@d-baker
d-baker / svg-bug.md
Last active August 29, 2015 14:13
Safari SVG <image> bug solution (kinda)
  • The <image> tag in SVG is used to include a bitmap image inside an SVG.
  • Safari (along with some other lesser-known browsers: Luakit, DWB, Rekonq, Konqueror) won't render <image> tags in an SVG unless the SVG is contained in a <object> tag.
  • If you want your <object> to be a clickable link, you need to add object { pointer-events: none} to your CSS.
  • Unfortunately, this doesn't appear to always work. I had 2 <object>s on one page that had similar CSS rules, and only one of them became clickable when I added the object { pointer-events: none} rule. There is a documented bug in webkit from 2011 that seems relevant to this problem, but it's a mystery to me.
  • The solution in my case was to convert the bitmap to a vector path. You can do this in Inkscape with Path -&gt; Trace bitmap. As long as you're not trying to include photographs in the middle of your SVG (why on earth would you want to do that!!) then there probably isn't anything wrong with this approach.
@d-baker
d-baker / vocab-template.txt
Last active August 29, 2015 14:10
starting points for learning a new language (or designing one)
PHRASES
Hello
Goodbye
Sorry
Thankyou
Yes
No
How are you?
Goodnight
Good morning
@d-baker
d-baker / audiohack.js
Last active August 29, 2015 14:08
HTML5 audio loading efficiency hack to be called on play()
// an array of the src attributes of every audio element on the page (assumes sources are already set, obviously)
var sources = [];
$("audio").each (function(i) {
$(this).attr("id", i.toString());
sources.push($(this).find("source").attr("src"));
});
// call this function when the user clicks the play button
// $target is a jQuery object containing the "path" to your audio elements in the dom
function hack($target) {
@d-baker
d-baker / countdata.txt
Last active August 29, 2015 14:05
botlang word analysis (updated to include long words)
============================================================
VERY SHORT
============================================================
íċ | reward
et | young
ís | skirt
ip | reason
du | purpose
an | strong
@d-baker
d-baker / .tmux.conf
Created August 13, 2014 08:45
tmux config, don't ask me how it works
bind R source-file ~/.tmux.conf \;
#------------------------------------------------------------------------
# Keys
#------------------------------------------------------------------------
# replace the default prefix key (Ctrl-B)
unbind C-b
set -g prefix C-a
bind C-a send-prefix
bind a send-prefix