Skip to content

Instantly share code, notes, and snippets.

View jeremyw's full-sized avatar

Jeremy Weiskotten jeremyw

View GitHub Profile

Keybase proof

I hereby claim:

To claim this, I am signing this object:

{
"data":[
{
"happy":true,
"created_at":"2020-01-01T05:10:30Z"
},
{
"happy":false,
"created_at":"2020-01-02T13:00:00Z"
},
@jeremyw
jeremyw / accounts_controller.rb
Created September 29, 2012 21:25
Testing Rails 4 strong parameters
class AccountsController < ApplicationController
def update
@account = Account.find(params[:id])
respond_to do |format|
if @account.update_attributes(account_params)
format.html { redirect_to @account, notice: 'Account was successfully updated.' }
else
format.html { render action: "edit" }
end
@jeremyw
jeremyw / given.rb
Created April 30, 2012 21:05
Given an object, do something
def given(object)
yield(object) if object
end
given(Model.find_by_id(1)) { |obj| operate_on(obj) }
@jeremyw
jeremyw / guess.rb
Created December 3, 2011 19:17
Number guessing game for nubies
class Array
def sum
inject(0) { |sum, value| sum += value }
end
def average
sum.to_f / size
end
end
:plain
<!--
testing
this is a multiline comment
hello
indent
-->
/
this is a
multiline
comment
@jeremyw
jeremyw / fluent_builder.java
Created January 15, 2011 15:17
Fluent Builder example
public class Car {
public static class Builder {
private int year;
private String make;
private String model;
private String color;
public Builder year(int year) {
this.year = year; return this;
}