Skip to content

Instantly share code, notes, and snippets.

View rosiehoyem's full-sized avatar

Rosie Hoyem rosiehoyem

View GitHub Profile
@rosiehoyem
rosiehoyem / _.md
Created February 11, 2014 18:59
Solar Production Data
@rosiehoyem
rosiehoyem / apis
Last active August 29, 2015 14:09
API Best Practicies
#API Best Practices
##Routes
Restricting Routes
resources :zombies, only: [:index, :show]
resources :humans, except: [:destroy, :edit, :update]
##Subdomain
Keeping our API under its own subdomain allows load balancing traffic at the DNS level.
resources :zombies, constraints: { subdomain: 'api' }
resources :humans, constraints: { subdomain: 'api' }
@rosiehoyem
rosiehoyem / app_model_person.rb
Last active August 29, 2015 14:11
Ruby Transactions
class Person < ActiveRecord::Base
...
def destroy_door_access
if self.door_accesses.first
self.door_accesses.first.destroy
else
true
end
@rosiehoyem
rosiehoyem / digitize_step_model.rb
Last active August 29, 2015 14:11
Meta Programming: instance_variable_set() and instance_variable_get()
# /app/models/digitize_step
class DigitizeStep < ActiveRecord::Base
belongs_to :process_step
end
@rosiehoyem
rosiehoyem / app_controllers_digitize_steps_controller.rb
Last active August 29, 2015 14:11
Forms, Complex Data Models and AJAX
# /app/controllers/digitize_steps_controller.rb
...
responds_to :js
...
def form
end
...
@rosiehoyem
rosiehoyem / blog_remind.coffee
Created February 2, 2015 21:59
Blog Reminder Script for Hubot
# Description:
# Forgetful? Add reminders
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
@rosiehoyem
rosiehoyem / gemfile.rb
Created March 14, 2015 19:27
My preferred Ruby stack
source 'https://rubygems.org'
gem 'rails', '4.1.1'
gem 'pg'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'therubyracer', platforms: :ruby
gem 'devise'
@rosiehoyem
rosiehoyem / checkout_controller.rb
Last active August 29, 2015 14:17
Tracking Checkouts
class CheckoutsController < ApplicationController
...
def create
@checkout = @item.checkouts.build(checkout_params)
respond_to do |format|
if @checkout.save
if @checkout.reservation == true
@checkout.create_activity :reservation, options = { owner: Person.find(@checkout.checked_out_by), recipient: @item, approved_by_id: @user.id }
else
@rosiehoyem
rosiehoyem / Rosie's Profile
Last active December 23, 2015 18:59
This is my profile info.
Name: Rosie Hoyem
Github: http://github.com/rosalita
Blog: http://rosiehoyem.com/
Tagline: Urbanist, Energy Wonk, Programmer
Profile Picture: http://nyobetabeat.files.wordpress.com/2012/09/avi_026-1.jpg
Treehouse Account: http://teamtreehouse.com/rosiehoyem
CoderWall Account: https://coderwall.com/rosalita
CodeSchool Account: http://www.codeschool.com/users/rosalita
Favorite Websites:
@rosiehoyem
rosiehoyem / Alien PB & J
Created September 24, 2013 03:06
How to build a peanut butter and jelly sammy-samich.
1. Begin by picking up the peanut butter containing and grasp the metal lid. Turn it is a counter clockwise direction until it is dislodged from the container. Place the open jar and cover on the table.
2. Repeat step 1 with the jam jar.
3. Gently grasp the open end of the bread bag an remove the plastic closing mechanism.
4. Reach inside the bag and remove two precut sections, or slices, of the bread substance.
5. Place the two slices of bread slide by side, broad faces down on the plate.
6. Take the knife (the skinny metal object approximately 8 inches long) and insert it into the open peanut butter jar 2 inches, then tilt it to an angle of 30 degrees.
7. Remove the knife and some of the peanut butter material.
8. Light press the flat side of the knift to the large face of one of the pieces of bread gently move the knift paralel to the bread, smearing the peanut butter material over the full face to a depth of between 1/8 to 1/4 inch in thickness.
Repeat step X with the jam jar and the other piece of bread