Skip to content

Instantly share code, notes, and snippets.

View duhaime's full-sized avatar

Douglas Duhaime duhaime

View GitHub Profile
@henrik
henrik / ocr.markdown
Created March 3, 2012 17:07
OCR on OS X with tesseract

Install ImageMagick for image conversion:

brew install imagemagick

Install tesseract for OCR:

brew install tesseract --all-languages

Or install without --all-languages and install them manually as needed.

@casschin
casschin / gist:1990245
Created March 7, 2012 01:16
Python webdriver api quick sheet
### Locating UI elements ###
# By ID
<div id="coolestWidgetEvah">...</div>
element = driver.find_element_by_id("coolestWidgetEvah")
or
from selenium.webdriver.common.by import By
element = driver.find_element(by=By.ID, value="coolestWidgetEvah")
# By class name:
class ApplicationController < ActionController::Base
...
#Problem:
#In rails 3.0.1+ it is no longer possible to do this anymore;
# rescue_from ActionController::RoutingError, :with => :render_not_found
#
#The ActionController::RoutingError thrown is not caught by rescue_from.
#The alternative is to to set a catch-all route to catch all unmatched routes and send them to a method which renders an error
#As in http://techoctave.com/c7/posts/36-rails-3-0-rescue-from-routing-error-solution
@dstroot
dstroot / install-redis.sh
Created May 23, 2012 17:56
Install Redis on Amazon EC2 AMI
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://raw.github.com/gist/2776679/04ca3bbb9f085b192f6aca945120fe12d59f15f9/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"
@crtr0
crtr0 / client.js
Created June 8, 2012 17:02
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
@timoxley
timoxley / drop_collections.js
Created July 27, 2012 17:30
mongoose drop collections helper
var async = require('async')
var _ = require('underscore')
var Helpers = function(mongoose) {
this.mongoose = mongoose || require('mongoose')
this.dropCollections = function(callback) {
var collections = _.keys(mongoose.connection.collections)
async.forEach(collections, function(collectionName, done) {
var collection = mongoose.connection.collections[collectionName]
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@ebidel
ebidel / gist:3723309
Created September 14, 2012 17:14
Spotlight bookmarklet
// Save this in a bookmarklet and click it on a page:
javascript:(function(){function d(a,c){document.body.style.webkitClipPath="circle("+a+"px, "+c+"px, "+b+"px)"}var b=90;window.addEventListener("mousemove",function(a){d(a.pageX,a.pageY)});window.addEventListener("mousewheel",function(a){if(a.shiftKey){a.preventDefault();var c=a.wheelDeltaY;b+=-c;b=0<c?Math.max(90,b):Math.min(b,window.innerHeight/2);d(a.pageX,a.pageY)}})})();
// Or paste this in the console and mouse over the page.
// SHIFT+mousewheel scroll makes the circle bigger/smaller.
(function() {
var radius = 90; // px
@zackrw
zackrw / Gemfile
Created September 27, 2012 16:16
Yale CAS and user info with Rails (after security "upgrade" on LDAP)
#
## Add the rubycas-client gem to your Gemfile and run bundle install
#
gem 'rubycas-client'
gem 'mechanize'
@mbostock
mbostock / .block
Last active October 31, 2023 14:57 — forked from mbostock/.block
Radial Tidy Tree
license: gpl-3.0
border: no
height: 1060
redirect: https://beta.observablehq.com/@mbostock/d3-radial-tidy-tree