Skip to content

Instantly share code, notes, and snippets.

View jamonholmgren's full-sized avatar

Jamon Holmgren jamonholmgren

View GitHub Profile
View failure_app.rb
class FailureApp < Devise::FailureApp
def respond
# We override Devise's handling to throw our own custom errors on AJAX auth failures,
# because Devise provides no easy way to deal with them:
if request.xhr? && (warden_message == :unconfirmed || warden_message == :invalid)
if warden_message == :unconfirmed[:alert] = "You need to confirm your account before continuing."
elsif warden_message == :invalid
user = Store::User.where(email: params[:user][:email].to_s).first

Keybase proof

I hereby claim:

  • I am jamonholmgren on github.
  • I am jamon ( on keybase.
  • I have a public key whose fingerprint is D738 5A6B BFCE 3E63 A066 7EE4 97DC 65B8 5AAC A688

To claim this, I am signing this object:

jamonholmgren / case-switch-bm.rb
Last active August 29, 2015 13:58
View case-switch-bm.rb
require 'benchmark'
def with_if_else(symbol)
if symbol == :success
elsif symbol == :error
elsif symbol == :warn
elsif symbol == :info
jamonholmgren / chaining-1.rb
Last active August 29, 2015 13:58
Chaining styles.
View chaining-1.rb
.joins("LEFT JOIN users ON = schools_users.user_id")
View pm_slide_menu.rb
class AppDelegate < PM::Delegate
def on_load(app, options)
open_slide_menu true), left: true), right: true)
# Docs here:
def open_slide_menu(middle_screen, sides={})
middle = middle_screen && middle_screen.navigationController || middle_screen
View espn_mock_response.rb
View my_obj_spec.rb
class MyObj
def now(&callback)
return @my_ivar if @my_ivar"a").async do
sleep 0.1 # simulate an http response
Dispatch::Queue.main.sync do
@my_ivar = { result: "real" } @my_ivar
View ProSwift.swift
import UIKit
import ProSwift
class HomeScreen: ProSwiftScreen {
let title = "Home Screen"
func onLoad() {
open(OtherScreen(navBar: true))
View teams_screen.rb
class TeamsScreen < PM::GroupedTableScreen
title "NBA Teams"
def table_data
title: "Atlantic",
cells: [
{ title: "Boston Celtics", action: :select_team, arguments: { team: "Boston Celtics" } },
{ title: "Brooklyn Nets", action: :select_team, arguments: { team: "Brooklyn Nets" } },
{ title: "New York Knicks", action: :select_team, arguments: { team: "New York" } },
View set_if.rb
class Object
def set_if(prop, val)
send "#{prop}=", val unless val.nil?
r ="wat")
r.set_if(:item, "no")
r.item # => "no"
r.set_if(:item, nil)