Skip to content

Instantly share code, notes, and snippets.

require 'pry'
class SearchLoopingTwo
def self.chop(query, col)
left = 0
right = col.count - 1
middle = col.count / 2
#binding.pry if query == 5
while right >= left do
@aokolish
aokolish / anagrams.txt
Created September 22, 2012 21:16
list of anagrams
barrette batterer
barye beray yerba
basally salably
basaltic cabalist
base besa sabe
basion bonsai sabino
basketwork workbasket
bastille listable
bat tab
batcher brachet
@aokolish
aokolish / tmux.md
Created October 13, 2012 16:47
quick way to kill all tmux sessions

This is the quickest way I've found to kill all tmux sessions

# detach from each session
<prefix>d

# kill tmux and all sessions
tmux kill-server
@aokolish
aokolish / reveal-options.js
Created October 22, 2012 06:27
Foundation 3 Reveal Options
$('#myModal').reveal({
animation: 'fadeAndPop', // Possible options: fade, fadeAndPop, none
animationSpeed: 300, //Speed at which the reveal should show. How fast animtions are
closeOnBackgroundClick: true, //Should the modal close when the background is clicked?
dismissModalClass: 'close-reveal-modal', //Specify a class name for the 'close modal' element.
open: function(){}, //callback function that triggers 'before' the modal opens.
opened: function(){}, //callback function that triggers 'after' the modal is opened.
close: function(){}, //callback function that triggers 'before' the modal prepares to close.
closed: function(){} //callback function that triggers 'after' the modal is closed.
});
@aokolish
aokolish / commands.sh
Created February 10, 2013 20:04
how to get spinach working with zeus
zeus init # => creates custom_plan.rb and zeus.json
@aokolish
aokolish / .simplecov
Last active December 13, 2015 22:08
how to get simplecov results when running specs from zeus.
require 'simplecov'
SimpleCov.configure do
SimpleCov.refuse_coverage_drop
add_filter "/spec/"
add_filter "scraper.rb" # don't care that this is spaghetti code
add_filter "error_messages_helper.rb"
add_filter "/config/"
add_filter "controller"
SimpleCov.minimum_coverage 93
end
require 'active_support/core_ext'
def dates_with_no_changes(employment_dates)
dates = []
employment_dates.each do |date|
dates << date[:start_at].to_date
if date[:end_at].nil?
dates << Date.current.next_year
else
dates << date[:end_at].to_date
def validate_messages(message)
message.split(' ').each do |msg|
if valid? msg
puts msg + " VALID"
else
puts msg + " INVALID"
end
end
end
class Dependencies
def initialize
@dependencies = Hash.new {|h,k| h[k] = []}
end
def add_direct item, new_dependencies
@dependencies[item] += new_dependencies
end
def dependencies_for item
@aokolish
aokolish / search.exs
Last active June 16, 2016 23:34
binary search. `elixir search.exs` to run this. assuming you have elixir (`brew install elixir`)
defmodule Search do
def chop(_val, []), do: -1
def chop(val, [head|tail]) when tail == [] do
if val == head, do: 0, else: -1
end
def chop(val, list) do
chop(val, 0, length(list) - 1, list)
end