Skip to content

Instantly share code, notes, and snippets.

View JustSilverman's full-sized avatar

Justin Silverman JustSilverman

View GitHub Profile
def create_pets_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetsApi.create_pets ..."
end
# resource path
local_var_path = "/pets".sub('{format}','json')
# query parameters
query_params = {}
require_relative 'geocoder'
require 'shoulda-matchers'
require 'geocoder'
require 'debugger'
class ActivityCluster
MAX_ROUTE_LENGTH = 4
MAX_DISTANCE = 20
@JustSilverman
JustSilverman / _post_row.html.erb
Last active December 14, 2015 20:29
Rails Ajax Snippets
<li><%= post.content %></li>
@JustSilverman
JustSilverman / example.rb
Last active December 14, 2015 16:19
Order by count of active record relations
class Topic < ActiveRecord::Base
has_many :votes
# Something that provides the result of the method below,
# but without dominating the db
#SQL would look something like this
# SELECT topics.*, COUNT(id) as vote_count from topics
# join on votes where topic_id = topics.id
# group_by(topic_id)
# order by (vote_count)
@JustSilverman
JustSilverman / some_file.rb
Created March 4, 2013 22:39
This gist has been created from CodeCred.me
def some_method
puts "foo"
end
@JustSilverman
JustSilverman / gist_1
Created March 4, 2013 07:49
This needs to be updated
Justin
Components
1. Database - Text file (maintains each list item)
2. User device - Takes input and displays output to user
3. Middleman - Translates between database and user device
- (i.e. takes input from user device and tells database to save it)
- (i.e. asks database for current list or specific list items)
Potential Classes
ListItem - (id, task (text), status)
List - Array ListItem objects
@JustSilverman
JustSilverman / gist:4658893
Created January 28, 2013 20:52
Deaf Grandma
def deaf_grandma
loop do
response = gets.chomp
if response == "I love ya, Grandma, but I've got to go."
break
elsif curse_word_check(response)
puts "Make your own Fucking meatloaf"
elsif response.upcase == response
puts "NO, NOT SINCE 1983!"
else
@JustSilverman
JustSilverman / inverse_of_example.rb
Last active December 10, 2015 23:19
Association using :inverse_of option.
class Company < ActiveRecord::Base
has_many :users, :inverse_of => :company
end
class User < ActiveRecord::Base
belongs_to :company, :inverse_of => :users
end
# Code from the Consle