Skip to content

Instantly share code, notes, and snippets.

# Before - NoteTextStorage is
# tightly coupled
class NotePresenter
def initialize
@note_storage = NoteTextStorage.new
end
def pending_notes
notes = @note_storage.get_all
notes.select { |n| n.pending? }
end

Installing Node Version Manager, Node and Yarn

Before you begin you will want to uninstall node and yarn if you already have it

brew uninstall yarn brew uninstall node

and manually remove yarn with

rm -f /usr/local/bin/yarn

package main.scala
import org.mongodb.scala.bson._
import org.mongodb.scala.bson.collection.mutable.Document
object RecordTransform {
def foldToDocument(results: Document, row: org.apache.spark.sql.Row): Document = {
var month_results = results.get[BsonDocument](row.getInt(0).toString)
var results_doc = month_results match {
case Some(doc) => doc

BACK-END WEB DEVELOPMENT

GeneralAssemb.ly

Install Git, Ruby, and Heroku

Mac Users

Generate a new key pair, then add the public key to your ~/.ssh/authorized_keys but with command="/usr/local/bin/tmux a -t pair" before it like below

command="/usr/local/bin/tmux a -t pair" ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDMRp0PGmJoycjFN7mJOQx0NcQD76xQrBBAAE6P60tK+3Zvf/gIu/5zvChP05tPT5ecMajxhOKsmtriL5ZRyyzxRja+W3+egZrEPoOAIDxVidX2T1nJpskVAWxqq7G0yueu8n8LrNe8fDUEvOswUzHVnkLp5ybZnQqJkBbZkS/KnQ==

Then you can give the private key to a friend and they'll only be allowed to connect when you have started a new tmux session with: tmux new-session -s pair

LeadGeneration::Lead.stub(:scrape_contact_from) do |email, attributes={}|
FactoryGirl.build :contact, attributes
end
module Enumerable
def collect_if
collect { |e| yield e }.reject &:nil
end
end
shared_examples_for 'a contact' do |options={}|
it { should be_a(Contact) }
its(:first_name) { should ==(first_name) }
its(:last_name) { should ==(last_name) }
its(:email) { should ==(email) }
unless options[:except_a_phone_number]
it "should scrape the phone number" do
subject.extended_contact_data_attributes[:phone_numbers].first[:value].should ==(phone_number)
end
@bill-transue
bill-transue / .bash_profile
Created February 15, 2013 18:54
.bash_profile to override read-only TMOUT variable
if [ ! -z "$TMOUT" ]; then
env -i bash --init-file ~/.bash_profile
fi
# .bash_profile
export SHELL='/bin/bash'
export HOME='/home/bill.transue'
# git bash prompt
export PS1='\u@\h:\W$(__git_ps1 " (\[\033[32m\]%s\[\033[m\])")$ '
def collect_options_for_select(collection, selected=nil, &block)
options_for_select collection.collect { |member| block.call member }, selected
end
def elevations_for_sub_component_select(sub_component)
collect_options_for_select sub_component.component.send(sub_component.class.name.underscore.pluralize).find_all_by_model_id(sub_component.model_id), url_for do |sub_component|
if sub_component.is_a? SubComponentTemplate
[ sub_component.location, edit_admin_component_sub_component_path(sub_component.component, sub_component) ]
else
[ sub_component.location, edit_component_sub_component_path(sub_component.component, sub_component) ]