Skip to content

Instantly share code, notes, and snippets.

@TalkativeTree
TalkativeTree / .bash_aliases
Created September 28, 2016 21:53
Bash Aliases
# Alias for Rails
alias rs="rails s"
alias rc="rails c"
alias restart_sound="sudo kill -9 `ps ax|grep 'coreaudio[a-z]' | awk '{print $1}'`"
alias myaliases='less ~/.bash_aliases'
alias bashp='subl ~/.bash_profile'
alias basha='subl ~/.bash_aliases'
alias bashh='subl ~/.bash_history'
@TalkativeTree
TalkativeTree / test.scss
Created February 16, 2014 05:01
Useful test function to test complicated Sass functions.
@function test($statement, $assertion, $expectation) {
@if $assertion != $expectation {
$result: "FAIL";
@return "____ #{$result} ____ " + $statement + " ____ Expected #{$assertion} to equal EXPECTATION: #{$expectation}";
}
@if $assertion == $expectation {
$result: "PASS";
@return "____ #{$result} ____ " + $statement;
}
}
class Api::PostsController < Api::Base
def create
service = PostService.new
service.delegate = Response.new(self)
service.create_new_post(params[:post])
end
end
class Response < SimpleDelegator
def new_post_created_successfully(post)
class PostsController
def new
@post = Post.new
end
def create
service = post_service.new
service.delegate = self
service.create_new_post(params[:post])
end
@TalkativeTree
TalkativeTree / public.rb
Created January 10, 2014 08:33
public methods
class Tester
public
def grab(string)
puts string
end
end
#=> nil
#> grab('asda')
#NoMethodError: undefined method `grab' for main:Object
#from (pry):7:in `__pry__'
@TalkativeTree
TalkativeTree / first_or_create.rb
Last active December 31, 2015 16:59
first_or_create with associations
SearchEngine.first.terms.where(name: term.downcase).first_or_create do |term|
SearchEngine.first.terms << term
end
@TalkativeTree
TalkativeTree / search_engine.rb
Last active December 31, 2015 14:29
models for an api that returns search results for terms from different search engines/apis.
class SearchEngine < ActiveRecord::Base
has_and_belongs_to_many :terms
has_many :searches, through: :terms
end
class Term < ActiveRecord::Base
has_and_belongs_to_many :searches
has_and_belongs_to_many :searche_engines
end
require 'benchmark'
require 'bigdecimal/math'
number = 0
array = Array.new(15){ Array.new(15, number += 1) }
def spiral(array)
spiral = []
spiral << array.delete_at(0)
return spiral.flatten if array.empty?
@TalkativeTree
TalkativeTree / resume.md
Last active December 19, 2015 03:49
Resume

Benjamin Angel

Professional Experience

Dev Bootcamp - April 2013 - July 2013

Student and Teaching Assistant

Going through Dev Bootcamp was like being thrown into a furnace. It taught me how resilient I can be, but also how to not let the stress and anxiety of work interfere with working on a team. I learned that whether or not I readily know how to solve a challenge, I can figure out the best path towards a solution.

For a more detailed recount on specific skills and experiences, check me out on Github, LinkedIn, and my blog

Rise Up – Full Circle September 2012-May 2013

@TalkativeTree
TalkativeTree / js_lessons.md
Last active January 6, 2017 06:08
Javascript algorithm exercises: 1

Challenge 1:

99 bottles of beer on the wall

Write a function bottle_song which takes as its input a positive integer n representing the number of starting bottles in the song. Pick a reasonable format and print out all the lines to the song.

Challenge 2: Roman Numerals

Write a method that converts an integer to its Roman numeral equivalent, i.e., 476 => 'CDLXXVI'.

Arabic ==> Roman 4 ==> IV