Skip to content

Instantly share code, notes, and snippets.

@austenito
austenito / gist:7798324
Created December 5, 2013 00:49
Work tmux config
# ~/.tmuxinator/ks.yml
name: ks
root: ~/repos/ks-dev/kitchensurfing
windows:
- vim: vim .
- console:
- logs:
layout: even-horizontal
@austenito
austenito / lololol.rb
Last active December 23, 2015 22:59 — forked from knt/lololol.rb
# I want to write a method that returns the first number in a sub array where the letter matches a passed in letter
# If passed in letter does not exist, it should return nil
a = [["a", 1], ["b", 2]]
# Implementation
def get_number_for_letter(arr, letter)
arr.detect(Proc.new { [] }) { |d| d.first == letter }[1]
end
# Error received for case where letter does not exist
# This might just be me not understanding how detect is supposed to work
@austenito
austenito / psql_cheat_sheet.md
Last active December 18, 2015 17:29
Terminal Cheet Sheet

Connecting: psql -U <username> -h <host> -d <database>

Modifying

  • connect to database \c database
  • create database create database <name>
  • drop database drop database <name

Exploring

@austenito
austenito / answers.md
Last active December 4, 2019 12:35
Answers to Ruby Interview Questions

Answers to [Ruby Interview Questions][1]

What is a class?

A text-book answer: classes are a blue-print for constructing computer models for real or virtual objects... boring.

In reality: classes hold data, have methods that interact with that data, and are used to instantiate objects.

Like this.

@austenito
austenito / interview.md
Last active June 7, 2020 19:37
Ruby Interview Questions

Ruby Questions

  • What is a class?
  • What is an object?
  • What is a module? Can you tell me the difference between classes and modules?
  • Can you tell me the three levels of method access control for classes and modules? What do they imply about the method?
  • There are three ways to invoke a method in ruby. Can you give me at least two?
  • Explain this ruby idiom: a ||= b
  • What does self mean?
@austenito
austenito / tmux.conf
Last active December 18, 2015 16:09
tmux conf for copying and pasting
# fixes mac os-x clipboad -> https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
set-option -g default-command "reattach-to-user-namespace -l zsh"
# vi mode
setw -g mode-keys vi
unbind p
bind p paste-buffer
bind -t vi-copy v begin-selection
bind -t vi-copy c copy-selection
module Router
class ApiConstraints
def initialize(options)
@version = options[:version]
@default = options[:default]
end
def default?
@default
end
@austenito
austenito / gist:5527039
Created May 6, 2013 18:26
delimited file reader
require "csv"
class DelimitedReader
def self.run(filename)
counter = 0
CSV.foreach(filename, { :headers => true }) do |row|
Merchant.find(row[0]).update_attribute(:merchant_profile_id, row[1])
counter += 1
Started POST "/items" for 127.0.0.1 at 2013-04-27 20:15:01 -0400
Processing by ItemsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"d0cFp62oxV8FMYZzo1qYKPWmIwZSR+sYl8acWmsJPuw=", "item"=>{"heading"=>"hihihihi", "description"=>"adfadfasdf", "tag_list"=>"", "latlon"=>{"latitude"=>"1", "longitude"=>"2"}, "photo"=>#<ActionDispatch::Http::UploadedFile:0x007fc76b245e70 @original_filename="chillin.gif", @content_type="image/gif", @headers="Content-Disposition: form-data; name=\"item[photo]\"; filename=\"chillin.gif\"\r\nContent-Type: image/gif\r\n", @tempfile=#<File:/var/folders/mt/h7jz7dhj04n5k3mh_gkt7m300000gp/T/RackMultipart20130427-14568-11ng10z>>}, "commit"=>"Create Item"}
Completed 500 Internal Server Error in 0ms