Skip to content

Instantly share code, notes, and snippets.

class Admin::TeamsController < ApplicationController
before_action :authenticate_admin!
def index
unless params[:q].blank?
term = "%#{params[:q]}%"
@team_list = Team.where "name LIKE ?", term
end
end
@csexton
csexton / kapow.zsh
Created August 2, 2015 15:59
Kapow function for zsh
# Kapow {{{
_rack_root_detect(){
setopt chaselinks
local orgdir=$(pwd)
local basedir=$(pwd)
while [[ $basedir != '/' ]]; do
test -e "$basedir/config.ru" && break
builtin cd ".." 2>/dev/null
basedir="$(pwd)"
@csexton
csexton / supplies.md
Created July 28, 2015 22:31
Things people might bring to Ruby for Good
  • Knives
  • Hot Pads/Trivets
  • Large Plastic Containers
  • Cutting boards
  • Large bowls
  • Cookie sheets for making bacon
  • Cast Iron Pans
  • Pots
  • Pans
  • Coffee Maker
class Parent
class Child < Parent
def self.cry
"(╥﹏╥)"
end
end
end
puts Parent::Child::Child::Child::Child::Child::Child::Child::Child.cry
class Robot
def say(msg)
`say "#{msg}"`
self
end
def beep
say "beep boop bling beep bee"
end
require 'pi_piper'
include PiPiper
watch pin: 23 do
puts "Pin changed from #{last_value} to #{value}"
end
@csexton
csexton / kit.json.jbuilder
Created June 2, 2015 21:59
Caching with jBuilder and Rails
json.cache! kit do
json.kit do
json.extract! kit, :id, :name, :created_at, :updated_at
json.name kit.name
# ...
end
end
@csexton
csexton / gist:09c2551d72937947849b
Created June 1, 2015 14:51
RadBeacon Test UUID
28482714-DD86-434B-AADA-E14BEA66F235
2015-05-20T02:13:23.081248+00:00 app[web.2]: NoMethodError (undefined method `[]' for nil:NilClass):
2015-05-20T02:13:23.081250+00:00 app[web.2]: lib/proximity_kit/base_resource.rb:11:in `all_from_url'
2015-05-20T02:13:23.081252+00:00 app[web.2]: lib/proximity_kit/base_resource.rb:20:in `from_url'
2015-05-20T02:13:23.081253+00:00 app[web.2]: app/models/concerns/sync_place.rb:6:in `sync_place'
2015-05-20T02:13:23.081254+00:00 app[web.2]: app/models/sync_to_proximity_kit.rb:13:in `perform'
2015-05-20T02:13:23.081256+00:00 app[web.2]: app/controllers/places_controller.rb:38:in `block in create'
2015-05-20T02:13:23.081257+00:00 app[web.2]: app/controllers/places_controller.rb:35:in `create'
% cat hi.swift
println("Hello, world!")
% swift hi.swift
Hello, world!