Skip to content

Instantly share code, notes, and snippets.

View jamesdabbs's full-sized avatar

James Dabbs jamesdabbs

View GitHub Profile
@jamesdabbs
jamesdabbs / git_hooks.md
Created February 18, 2015 20:28
Quick reference on some useful git hooks.
@jamesdabbs
jamesdabbs / curl.rb
Created February 17, 2015 17:57
A (deliberately not-so-great) example of making HTTP request from Ruby using curl
require 'json'
require 'pry'
url = "https://api.github.com/orgs/TIY-DC-ROR-2015-Jan/repos"
response = `curl #{url}`
data = JSON.parse response
# Try poking around here and taking a look at `data`
# binding.pry

Hello gist!

@jamesdabbs
jamesdabbs / ARGV and dispatch.md
Created February 16, 2015 23:59
A quick note answering a question about dispatching from ARGV

In working on her command line todo manager, Katie asked a good question about being able to use a NoMethodError. NoMethodError specifically applies to trying to call methods on an object and there isn't (an obvious) one here, but I wanted to suggest an idea. Notice that you probably have a big long where statement where each case is just "do the thing that the user typed in with whatever arguments they supplied". Here's one potential way to simplify that:

class Dispatcher
  def add
    ...
  end
  def list
    ...
 end
@jamesdabbs
jamesdabbs / sync
Created February 2, 2015 01:46
Sample script for syncing laptop with home server, suitable for cron-ing
#!/usr/bin/env ruby
require 'json'
require 'open3'
home = "/Users/james"
name = `hostname`.downcase
server = "walt.local"
mirror = "#{server}:/storage/mirrors/#{name}"
@jamesdabbs
jamesdabbs / good_ideas.rb
Created January 15, 2015 20:41
Production Ready™
require 'pry'
require 'binding_of_caller'
class Symbol
def and_then snd=nil
fst = self.to_s
binding.of_caller(1).eval %{
define_method :#{fst}_and_then_#{snd} do
send :#{fst}_without_#{snd}
send :#{snd}
@jamesdabbs
jamesdabbs / classes-quiz.rb
Created January 13, 2015 15:19
Short quiz on classes
# Download and run this file, and get the specs passing
# You might need to `gem install minitest`
require 'minitest'
class Dog
# You need to define this class so that the specs below pass
end
require 'minitest/autorun'
@jamesdabbs
jamesdabbs / hou-guest-lecture.md
Created January 12, 2015 17:11
HOU Guest Lecture

Quiz!

I've been reading Make It Stick (A+ would recommend), and trying to do more information-retrieval practice (as a good way to make information stick). This is ungraded, but should be pretty quick.

Find the sum of these numbers. HipChat me the sum -

5,11,87,49,52,99
20,5,67,34,12
92,57,91,77,45,29,56,38,18,68,92,26,42,55,46

Keybase proof

I hereby claim:

  • I am jamesdabbs on github.
  • I am jdabbs (https://keybase.io/jdabbs) on keybase.
  • I have a public key whose fingerprint is 8428 B038 A487 D956 2F63 174B FF49 F856 394F 613C

To claim this, I am signing this object: