Skip to content

Instantly share code, notes, and snippets.

View philosodad's full-sized avatar

J. Paul Daigle philosodad

View GitHub Profile
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
# tmux prefix
unbind C-b
set -g prefix C-o
# move around panes like in vim (only in tmux 1.6)
bind j select-pane -D
== Compilation error on file lib/phoenix/code_reloader.ex ==
** (CompileError) lib/phoenix/code_reloader.ex:61: function full_path/1 undefined
(stdlib) lists.erl:1336: :lists.foreach/2
(stdlib) erl_eval.erl:657: :erl_eval.do_apply/6
could not compile dependency phoenix, mix compile failed. You can recompile this dependency with `mix deps.compile phoenix` or update it with `mix deps.update phoenix`
@philosodad
philosodad / enum error
Last active August 29, 2015 14:23
Enumerable Not Implemented Error
protocol Enumerable not implemented for %Dashex.Project{__meta__: %Ecto.Schema.Metadata{source: "projects", state: :loaded}, badges: [%Dashex.Badge{__meta__: %Ecto.Schema.Metadata{source: "badges", state: :loaded}, id: 5, image_url: "https://img.shields.io/travis/bitpay/ruby-client.svg?style=flat-square", inserted_at: %Ecto.DateTime{day: 12, hour: 21, min: 57, month: 6, sec: 41, usec: 0, year: 2015}, name: "Travis", project: #Ecto.Association.NotLoaded, project_id: 6, updated_at: %Ecto.DateTime{day: 12, hour: 21, min: 57, month: 6, sec: 41, usec: 0, year: 2015}}, %Dashex.Badge{__meta__: %Ecto.Schema.Metadata{source: "badges", state: :loaded}, id: 8, image_url: "https://img.shields.io/codeclimate/github/bitpay/ruby-client.svg?style=flat-square", inserted_at: %Ecto.DateTime{day: 12, hour: 22, min: 0, month: 6, sec: 55, usec: 0, year: 2015}, name: "Code Climate", project: #Ecto.Association.NotLoaded, project_id: 6, updated_at: %Ecto.DateTime{day: 12, hour: 22, min: 0, month: 6, sec: 55, usec: 0, year: 2015}}], h
@philosodad
philosodad / symogrify.rb
Last active December 24, 2015 20:19
Monkey patch of the Hash class to convert all string keys to symbols at arbritray depth
require "minitest/autorun"
class Hash
def symogriform
symogriformed = {}
symogrified = self
symogrified.keys.each do |key|
if symogrified[key].is_a?(Hash)
symogrified[key] = symogrified[key].symogriform
end
end
@philosodad
philosodad / SvnHelper.java
Last active May 18, 2017 06:24
This gist is a solution to a code Kata I've used to teach a little bit about Mocking and Stubbing. The idea of the Kata is to use TDD to develop a method that will fetch a SVN repository and get the names of each directory entry in the repository. SvnHelperTest uses mocks, stubs, and partial mocks (spys) to test the method. The last time I taugh…
package svnhelpers;
import java.util.ArrayList;
import java.util.Collection;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.TransformerUtils;
import org.tmatesoft.svn.core.SVNDirEntry;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
@philosodad
philosodad / hashmogrify.rb
Created March 22, 2012 22:59
monkey patch of the enumerable class that adds a "to_hash" method
module Enumerable
def hashmogrify(&block)
hash = {}
self.each do |e|
result = block.call(e)
if result.is_a?(Array)
hash[result[0]] = result[1]
else
hash[result] = e
@philosodad
philosodad / binary_search_method.rb
Created December 19, 2011 05:41
Learn How You Fail
def binary_search search_array, key
if search_array[search_array.length/2] == key then return search_array.length/2 end
if search_array[search_array.length/2] < key then binary_search (search_array(search_array.length/2...search_array.length), key) end
if search_array[search_array.length/2] > key then binary_search(search_array(0..search_array.length/2), key) end
end
@philosodad
philosodad / fibs.io
Created November 18, 2011 19:43
Io Day Two
fiboRecursive := method(nth_value, if(nth_value <= 2, 1,
(fiboRecursive(nth_value - 2) + fiboRecursive(nth_value - 1))
))
fiboIterative := method(nth_value, value_list := list(0,1,1);
for(i, 0, nth_value,
if (value_list at (i), value_list at (i),
value_list append (value_list at (i-1) + value_list at (i-2) ) ) );
value_list at (nth_value) )
@philosodad
philosodad / outrage.io
Created November 15, 2011 04:16
Io Day One
"I am outraged at this outrageous abuse" println
OutragedGuy := Object clone
OutragedGuy rage := method("I am extremely outraged at this outrageous outrageousness!" println)
"Oh, really?" println
OutragedGuy rage
@philosodad
philosodad / day2_index_each.rb
Created November 12, 2011 22:10
7 languages Ruby Day 2
array2 = []
16.times{array2 << rand(100)}
[0,1,2,3].each{|index| 4.times{print array2[index], " ";index+=4};print "\n"}