Skip to content

Instantly share code, notes, and snippets.

View seeflanigan's full-sized avatar

Cory Flanigan seeflanigan

View GitHub Profile
@seeflanigan
seeflanigan / fix-func-name-errors.sh
Created December 8, 2016 21:37
`sed` onelines to fix `func-name` errors in `ESLint` per `airbnb/legacy` rules
#!/usr/bin/env bash
# Use cases
#
# Anonymous function expressions assigned by `=` operator to a variable:
# (with and without arguments)
#
# const aFunc = function () {};
#
# Anonymous function expressions declared as a property of an object:
def attrs
@attrs ||= Reading.new.attributes.keys.take(5).last(4)
end
def data
@data ||= File.read("tmp/output_small_test.csv")
end
def rows
data.split()
@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
@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 / 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 / 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 / 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]
require 'sinatra'
get '/' do
@name = # GET GIST HERE!!!
erb :home
end
@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)
@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