Skip to content

Instantly share code, notes, and snippets.

module AcceptsDelimtedIdStringFor
# accepts_delimited_id_string_for :careers
#
# becomes
#
# def career_id_strings=(delimited_string)
# self.careers = Career.where(:id => delimited_string.split(",")).all
# end
#
class Restaurant
attr_accessor :ratings, :cuisine, :price
def initialize(cuisine = nil, price = 0)
@ratings = []
@cuisine = cuisine
@price = price
end
@noelrappin
noelrappin / gist:3717270
Created September 13, 2012 20:16
Geoffrey Grossenbach's Prompt as a oh_my_zsh theme (see https://peepcode.com/blog/2012/my-command-line-prompt)
# Combined left and right prompt configuration.
local smiley="%(?,%{$fg[green]%}☺%{$reset_color%},%{$fg[red]%}☹%{$reset_color%})"
PROMPT='
%~
${smiley} %{$reset_color%}'
RPROMPT='%{$fg[gray]%} $(~/.rvm/bin/rvm-prompt)$(~/bin/git-cwd-info.rb)%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[blue]%} (%{$fg[red]%}"
@noelrappin
noelrappin / code_email.md
Created December 11, 2015 18:37
Code sample email

Hi,

We'd like to continue the application process with you.

For technical candidates, we ask that they submit a solution to a coding challenge. Take a look at this exercise: REDACTED

Here are a few things we'd like you to keep in mind as you work on this problem.

We encourage you to think of this in a real world context, meaning that a client really wants to DO THIS THING, (you can assume the client has a laptop with them and can run arbitrary command-line or web programs). In other words, we want you to solve the problem, not just the algorithm. How will the client run the program? How will the output be presented?

Here's a description that is roughly the problem I'm having:
The ember.js site I'm working on has a number of different screens
(deliberately using a word that has no ember connotations).
Let's say, for the sake of argument, 3 of them.
Each of these screens has their own normal route, controller, model,
template structure. This is all standard.
Now I want a dashboard. For the sake of argument, let's say I want
@noelrappin
noelrappin / description.md
Last active December 14, 2015 04:48
Problem I'm having with Ember and Jasmine

I'm trying to run an Ember controller in a Jasmine test, and it's giving me some trouble.

This spec works, in that it renders the controller, and most of the controller is rendered accurately and can be tested.

However, there is clearly a difference between how I'm setting up these objects in the test, and how Ember sets them up at run time, because parts of the controller are not working in the test...

Details:

  • The itemController is not accessed at all, which means that the reference to "startDateDisplay" (which is defined in the item controller) comes up empty.
@noelrappin
noelrappin / index_controller_spec.js
Last active December 16, 2015 23:59
Ember integration test
// This is my attempt at an ember controller integration test based on http://jsfiddle.net/ekidd/hCsws/
// It almost works..
// Here's what doesn't work: Template lookup
// In the view description, I have
// template: Ember.TEMPLATES.index
//
// it should be
class UnclaimedSlowTestException < Exception
THRESHOLD = 1
def initialize(example)
@example = example
end
def message
"This spec at #{@example.metadata[:location]} is slower than #{THRESHOLD} seconds.
### Keybase proof
I hereby claim:
* I am noelrappin on github.
* I am noelrap (https://keybase.io/noelrap) on keybase.
* I have a public key whose fingerprint is 9D10 BE61 2831 3E78 345C F8B3 789C 84D0 FC55 9E5B
To claim this, I am signing this object: