Skip to content

Instantly share code, notes, and snippets.

View iandanforth's full-sized avatar

Ian Danforth iandanforth

View GitHub Profile
@iandanforth
iandanforth / jupyter-scroll.txt
Created December 3, 2017 22:59
Enable smooth scrolling with arrow keys in Jupyter Notebooks
%%javascript
Jupyter.keyboard_manager.command_shortcuts.remove_shortcut('up');
Jupyter.keyboard_manager.command_shortcuts.remove_shortcut('down');
@iandanforth
iandanforth / exhaust_ports.py
Last active October 3, 2016 00:53
Reproduction of port exhaustion in chromedriver
from selenium import webdriver
driver = webdriver.Chrome()
driver.set_window_size(640, 480)
driver.get("http://www.google.com")
ports_used = 0
while True:
try:
resp = driver.execute_script("")
@iandanforth
iandanforth / File
Created April 27, 2016 22:39
Leaderboard
Leaderboard wireframe.
@iandanforth
iandanforth / remote-debugger-phantomjs.md
Created December 10, 2015 21:01
How do I enable remote debugger for python webdriver phantomjs?

I couldn't find this documented anywhere, but the option exists and lives in the code!

If you're using python, selenium, and phantomjs, somewhere in your code you have a line like this:

from selenium import webdriver
driver = webdriver.PhantomJS()
@iandanforth
iandanforth / canvascapture.md
Last active October 5, 2022 10:57
Capture WebGL frames to disk

How to capture WebGL/Canvas by piping data over a websocket.

This Gist builds on https://gist.github.com/unconed/4370822 from @unconed.

Instead of the original method which writes to the browsers sandboxed filesystem here we use a websocket connection provided by websocketd to pipe image data to a short python script that writes out the .png files to disk.

Install websocketd

@iandanforth
iandanforth / wtfdiv.md
Last active August 29, 2015 14:28
Where the F#$K is my div?!

So you're trying to build a nice slide-in menu. Something that shows up from the bottom of your app when a user clicks a menu button. Here are a collection of things I wish I had known a few hours ago.

You can't do this with just CSS (or you shouldn't)

You need to have a bit of JavaScript to change a class on the element you're trying to animate.

You need a position: relative parent, a regular child div, and a position: absolute child with left and bottom set.

If you don't have a position: relative parent, your absolutely positioned div (the one you want to slide on screen) may not

@iandanforth
iandanforth / iteritems.sublime-snippet
Last active August 29, 2015 14:23
Sublime Snippet: JavaScript functional equivalent of Python's dict.iteritems() or dict.items()
<snippet>
<content><![CDATA[for (var ${20:key} in ${1:Thing}) {
if (${1:Thing}.hasOwnProperty(${20:key})) {
var ${300:val} = ${1:Thing}[${20:key}];
${4000}
}
};]]></content>
<tabTrigger>for</tabTrigger>
<scope>source.js</scope>
<description>for key, val in object</description>
@iandanforth
iandanforth / gist:68b59a4c6c5fc789791a
Last active August 29, 2015 14:20
Error - backbone - Synchronous XMLHttpRequest on the main thread is deprecated
Descriptions:
ready event fires twice
backbone router runs twice
router won't render sub-pages
Long description:
My backbone app wouldn't render any pages that were not at the root of the
tree. For example /robots would render fine but /robots/id/1 would not.
@iandanforth
iandanforth / pixymoninstall.md
Last active August 29, 2015 14:04
How to Install PixyMon (Pixy / CMUCam5 GUI) on Ubuntu 14.04

Install the stable version of PixyMon

cd ~/
mkdir pixy
cd pixy
wget http://cmucam.org/attachments/download/1007/pixymon_src-0.1.49.tar.gz
tar xvfz pixymon_src-0.1.49.tar.gz 
cd pixymon-0.1.49/
sudo cp pixy.rules /etc/udev/rules.d/

sudo apt-get install -y build-essential qt4-qmake uic-qt4 libqt4-dev-bin libqt4-dev libusb-1.0-0-dev

@iandanforth
iandanforth / GoalDirectedBehaviorInCLA
Last active August 29, 2015 13:57
A detailed example of how a Goal can influence behavior in CLA
The answer is to allow cells that are both *predicted* and *desired* to become
active. Not just put into a predictive state.
Let me illustrate.
Let's say you have a world with three rooms in a row with letter labels:
ABC
In this world you have a creature that can go Left, go Right, or Stay where it