Skip to content

Instantly share code, notes, and snippets.

View jeffreybaird's full-sized avatar

Jeffrey Baird jeffreybaird

View GitHub Profile

###Hello Review Session!

Below I have included a fairly complex hash called 'us_government' the following questions will be about going through this hash. Write the code that answers each of the questions below.

  1. Return an Array of of the names of all the Supreme Court Justices
  2. access the hash with the name attribute "Senator 18"
  3. Print out the names of all the Representatives to the console
  4. Return an array with the names of all members of the government
  5. Remove "Senator 6" from the hash
  6. Add "Representive 20" to the house of representatives
@jeffreybaird
jeffreybaird / keybase.md
Created March 21, 2014 16:57
keybase.md

Keybase proof

I hereby claim:

  • I am jeffreybaird on github.
  • I am jeffreybaird (https://keybase.io/jeffreybaird) on keybase.
  • I have a public key whose fingerprint is F6EE 23D3 5669 09FD 77EE 0FA2 6752 C11E 4841 E0B9

To claim this, I am signing this object:

-----BEGIN PGP MESSAGE-----
Version: Keybase OpenPGP v0.1.1
Comment: https://keybase.io/crypto
wcBMA7m3rH38ud1BAQf9GSKMVwzMQbBiFDYI+L/3X2XdDl/Kq9QZNSq3350MPkJI
vNHaZdcCCrOMf8yksG3cQjgK373bU2YWU5i2eyUZzHMzpntC8MLPT2hr27PBIOvL
HjB7KXchfDJfReIEJRUdFMsZjgPqsNkbofLg/kB3ZeA86FkV/nixMTbdwS3Iaska
SVziby35cHHODIEp6wGVOwQO9BrrN8pFjRfNI1MflOIVKaY4laCds3hMZDVRVMo7
HIX2ULaA4otw+Ocob1gT/Eo4Z3xVBd7N2mxgnYNMl9LILMZdNM+V/FtXCFlcnVHJ
wFa0RTdJ3/YilTRzTC3FThcioyQSSy7JBgNOOyICOtLA9gEuetDo/uRxsewaBUP8
Node '[email protected]' not responding to pings.
config is OK
Exec: /usr/local/Cellar/riak/1.4.8/libexec/erts-5.9.1/bin/erlexec -boot /usr/local/Cellar/riak/1.4.8/libexec/releases/1.4.8/riak -config /usr/local/Cellar/riak/1.4.8/libexec/etc/app.config -pa /usr/local/Cellar/riak/1.4.8/libexec/lib/basho-patches -args_file /usr/local/Cellar/riak/1.4.8/libexec/etc/vm.args -- console
Root: /usr/local/Cellar/riak/1.4.8/libexec
{error_logger,{{2014,6,10},{9,6,37}},"Protocol: ~p: register error: ~p~n",["inet_tcp",{{badmatch,{error,duplicate_name}},[{inet_tcp_dist,listen,1,[{file,"inet_tcp_dist.erl"},{line,70}]},{net_kernel,start_protos,4,[{file,"net_kernel.erl"},{line,1314}]},{net_kernel,start_protos,3,[{file,"net_kernel.erl"},{line,1307}]},{net_kernel,init_node,2,[{file,"net_kernel.erl"},{line,1197}]},{net_kernel,init,1,[{file,"net_kernel.erl"},{line,357}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,304}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,227}]}]}]}
@jeffreybaird
jeffreybaird / question.md
Last active June 22, 2016 18:29
Question about the phoenix.gen.json generator.
$mix phoenix.new testapi
$cd testapi
$mix ecto.create
$mix phoenix.gen.json User users fullname:string email:string

Add the resource to your api scope in web/router.ex:

resources "/users", UserController, except: [:new, :edit]

under the api block

@jeffreybaird
jeffreybaird / linnked_list.rb
Created December 4, 2015 20:59
A linked list implementation
class LinkedList
attr_reader :tail
def initialize(head=nil, tail=NullList.new())
raise ArgumentError unless tail.is_a?(LinkedList) || tail.is_a?(NullList)
@head = head.is_a?(Head) ? head : Head.new(head)
@tail = tail
end
def head
puts('. '* 31 +'.')
puts(('. '* 7) + ('X ' * 17) + ('. ' * 8))
puts(('. '* 6) + 'X ' + ('. ' * 17) + 'X ' + ('. ' * 7))
puts(('. '* 5) + 'X ' + ('. ' * 19) + 'X ' + ('. ' * 6))
puts(('. '* 4) + 'X ' + ('. ' * 21) + 'X ' + ('. ' * 5))
puts(('. '* 3) + 'X ' + ('. ' * 23) + 'X ' + ('. ' * 4))
puts(('. '* 2) + 'X ' + ('. ' * 25) + 'X ' + ('. ' * 3))
puts(('. '* 3) + 'X ' + ('. ' * 23) + 'X ' + ('. ' * 4))
puts(('. '* 4) + 'X ' + ('. ' * 21) + 'X ' + ('. ' * 5))
puts(('. '* 5) + 'X ' + ('. ' * 19) + 'X ' + ('. ' * 6))
@jeffreybaird
jeffreybaird / breakout.elm
Created April 15, 2016 19:33
Pertinent functions to breakout
type alias Game =
{
state : State
, player : Player
}
type State = Play | Pause
type alias Player =
Object {score : Int}
-- TYPE MISMATCH -------------------------------------------- test/ball_test.elm
The 2nd argument to function `withinBrick` is causing a mismatch.
38│ Ball.withinBrick ball brick
^^^^^
Function `withinBrick` is expecting the 2nd argument to be:
{ color : Color.Color, vx : Float, vy : Float, x : Float, y : Float }
efmodule Rumbl.UserController do
use Rumbl.Web, :controller
alias Rumbl.User
def index(conn, _params) do
case authenticate(conn) do
%Plug.Conn{halted: true} = conn ->
conn
conn ->
users = Repo.all(User)