Skip to content

Instantly share code, notes, and snippets.

class @Hello
constructor: ->
@greeting = "hello"
greet: =>
console.log @greeting
print_number: ->
number = 3
console.log "#{number} is a number"
@gabebw
gabebw / pop_poperator.swift
Last active October 24, 2015 07:01
POP POP
postfix operator ^^ {}
// `inout` means that you can't do `let l = [1]` then `l ^^` -- `l` must be a `var`
postfix func ^^<T>(inout array: [T]) -> [T] {
return [newArray.removeLast(), newArray.removeLast()]
}
@gabebw
gabebw / yam.rb
Created January 30, 2015 02:17
parse a yam
# Uses an algorithm originally developed by Gordon Fontenot: https://twitter.com/GFontenot/status/560984177672482817
# Translated into Ruby by Gabe Berke-Williams, 2015
Yam = String
class YamParser
def self.fromYam(yam)
"It's a fucking sweet potato"
end
end
it "returns a list of available cities" do
create(:city, name: "Boston")
get_index
expect(json_body).to eq({ cities: %w(Boston) })
end
def get_index
get "/api/cities", {}.to_json, default_headers.merge("HTTP_AUTHORIZATION" => token_header_value, "Authorization" => token_header_value)
@gabebw
gabebw / chat.rb
Last active August 29, 2015 14:10
require 'socket'
# Use your INTERNAL ip
me = { ip: '192.168.1.205', port: 55_555, name: 'Gabe' }
# Use your friend's EXTERNAL ip
friend = { ip: '50.187.42.170', port: 5_555, name: 'Edward' }
BasicSocket.do_not_reverse_lookup = true
@gabebw
gabebw / activerecord-relationships.md
Last active August 29, 2015 14:07
ActiveRecord Relations: `belongs_to` and `has_many`

belongs_to

Here's the [documentation].

Let's say we have this:

class Image
  belongs_to :user
end
@gabebw
gabebw / books.md
Last active August 29, 2015 14:05

Books

I like to read books, here are my thoughts about them.

Sci Fi

  • John Scalzi is thankfully prolific. If you haven't read anything by him, [Redshirts] is a meta exploration of Star-Trek-like shows. If you liked Galaxy Quest, you'll love it.
@gabebw
gabebw / list.md
Last active August 29, 2015 14:05
Book Recommendations

Lindsay Cade:

  • Red Mars Trilogy (hardish sci-fi).
  • Wool trilogy (fluffier but fun sci-fi).
  • The Golem and the Jinni (magical realism).
  • Halfway through Diaspora, is excellent but dense.

Kyle Fiedler

  • Sword of Truth series is my go to fantasy suggestion. Haven't read it in a couple years though. Not a dark comedy.
@gabebw
gabebw / how_to_pr.md
Created July 24, 2014 20:28
How to Read a Pull Request

How to Read a Pull Request

  1. Go to the main pull request URL. It should end in /pull/NUMBER. Look at the 3 tabs right under the PR title. You should be in the "Conversation" view.

  2. Read the PR title and the PR description. The description should tell you what the developer is trying to accomplish in this PR. This gives you some mental structure so you know what you're looking at. It can also tell you what doesn't belong in this PR.

@gabebw
gabebw / modules_and_inheritance.rb
Last active August 29, 2015 14:04
Exploring modules and inheritance in Ruby
module ModuleOne
def name
"Module 1"
end
end
module ModuleTwo
def name
"Module 2"
end