Skip to content

Instantly share code, notes, and snippets.

View seeflanigan's full-sized avatar

Cory Flanigan seeflanigan

View GitHub Profile
@seeflanigan
seeflanigan / description
Created December 6, 2011 19:56
Element no longer connected to DOM
Found by Dima Kovalenko
Selenium specs which call "wait for element to be visible" fail on an "Element no longer connected to DOM" error.
The problem occurs when the div appears briefly, then goes away. If the loop exits after the div is already off the screen, the call to "wait for element to be visible times out, and causes the spec to fail.
This issue can be elusive, only failing intermittently because sometimes the loop exits quickly enough to avoid producing the error. The fact that the div is displayed then hidden was the key to identifying and solving this bug in our test.
@seeflanigan
seeflanigan / appusers.rb
Created May 3, 2012 04:56 — forked from kartikrustagi/appusers.rb
Auth using Sinatra-Warden
require 'openssl'
class AppUser < Sequel::Model(:AppUsers)
AppUser.unrestrict_primary_key
def self.authenticate(username, password)
#TODO: Store salt in config
puts "In Auth"
user = self.first(:username => username)
@seeflanigan
seeflanigan / conway.clj
Created December 14, 2012 00:56
Conway's Game of Life in Clojure (with Venkat at CodeRetreat, Uncubed, 2012/01/21)
(ns game
(:use clojure.test))
(defn vitality [cell-state live-neighbors]
(or (= live-neighbors 3) (and cell-state (= live-neighbors 2))))
(defn count-live-neighbors [grid position]
(let [row (first position)
column (last position)]
(def neighbors
@seeflanigan
seeflanigan / player.rb
Last active December 20, 2015 09:09 — forked from Jimgerneer/gist:6105276
class Player
attr_accessor :warrior, :direction, :health, :hurt, :step
def initialize
self.direction = :backward
self.hurt = false
self.step = true
end
def play_turn(warrior)
require 'sinatra'
get '/' do
@name = # GET GIST HERE!!!
erb :home
end
@seeflanigan
seeflanigan / anagram.clj
Last active December 22, 2015 16:29 — forked from rjmcdonald83/anagram.rb
Anagram Solutions
(ns anagram
(:require [clojure.string :refer [lower-case split]]))
(defn- duplicate? [a b]
(= (lower-case a) (lower-case b)))
(defn- unique-candidates [source candidates]
(remove #(duplicate? % source) candidates))
(defn- canonicalize [word]
@seeflanigan
seeflanigan / the_answer.rb
Created October 4, 2013 21:22
Deep Thought
num = 1000000000000000000000000000000000000000000
(0..100).each_with_index {|n, i| puts n if num == 10 ** n }
@seeflanigan
seeflanigan / docker-compose.yml
Last active April 18, 2020 07:23
Docker Compose file for running Clojure Koans
koans:
image: clojure
command: lein koan run
volumes:
- ./clojure-koans:/clojure-koans
working_dir: /clojure-koans
repl:
image: clojure
command: lein repl
@seeflanigan
seeflanigan / git-oneline-date-and-message.sh
Created April 5, 2016 16:50
git oneline for short date and commit message within a range
git log --oneline --after="2016-03-28" --before="2016-04-03" --pretty=format:"%ad, %s" --date=short
@seeflanigan
seeflanigan / clean_string_attributes.rb
Last active April 8, 2016 17:07
Things we build when we don't read the docs in config/initializers/devise.rb
class User < ActiveRecord::Base
DO_NOT_MODIFY = ["encrypted_password", "state"]
def do_not_modify
DO_NOT_MODIFY
end
def strip_string_attributes
string_attributes.each do |k,v|
# this is a side-effect and mutates instance state