Skip to content

Instantly share code, notes, and snippets.

View neilmiddleton's full-sized avatar
🏠
Working from home

Neil Middleton neilmiddleton

🏠
Working from home
View GitHub Profile
@neilmiddleton
neilmiddleton / Gmail Style
Created February 5, 2013 10:52
Stylish Gmail Style
#gbx3, .gbes, #gbz, .aeG>.ov, #gbi4t, .TC, #oneGoogleWrapper #gb, #gbar-header #gb {
display: none !important;
}
.AOaixb.yRwDId.eub5Ne {
top: 120px !important;
}
#docs-header.docs-og-minibar #docs-titlebar-container {
top: -50px;
}
#gbu, #gbq, #gbx1 {
@neilmiddleton
neilmiddleton / routes.rb
Created February 14, 2013 15:55
wicked routes
resources :messages, :except => [:index] do
collection do
get :create_new, controller: 'messages/build', action: :create
end
resources :build, controller: 'messages/build'
end
@neilmiddleton
neilmiddleton / application_helper.rb
Created February 15, 2013 10:55
pricing formatting
def locale_from_currency(currency)
case currency
when :GBP
:en
when :USD
:en
when :EUR
:de
end
end
@neilmiddleton
neilmiddleton / en.yml
Created February 15, 2013 11:29
accommodation types
accommodation_types:
view_all: View all
host-family: Host Family
student-residence: Student Residence
hotel: Hotel
apartment-or-studio: Apartment or Studio
bed-breakfast: "Bed & Breakfast"
campus-residence: Campus Residence
def bookmark!
uri = Addressable::URI.new
uri.query_values = cleanse(params)
uri.path = request.env["REQUEST_PATH"]
session[:last_bookmark] = uri.to_s
end
def bookmark
session[:last_bookmark] ||= root_path
end
@neilmiddleton
neilmiddleton / heavy.rb
Created February 22, 2013 18:31
Nik's problem
def heavy_decimal_count(a,b)
heavy = []
(a..b).collect do |number|
chars = number.to_s.split('').collect{|x| x.to_i}
heavy << number if (get_avg(chars) > 7)
end
heavy
end
def get_avg(arr)
@neilmiddleton
neilmiddleton / heavy.rb
Created February 22, 2013 18:35
Nik's problem, but better
def heavy_decimal_count(a,b)
(a..b).select do |number|
chars = number.to_s.split('').collect{|x| x.to_i}
get_avg(chars) > 7
end
end
def get_avg(arr)
arr.inject{|sum,x| sum + x }.to_f / arr.size
end
@neilmiddleton
neilmiddleton / gist:5100375
Last active December 14, 2015 14:28
read_only
module ActiveRecord
class Base
def read_only?
ENV["AR_READ_ONLY"] ||= false
end
def before_destroy
raise ActiveRecord::ReadOnlyRecord if read_only?
end
@neilmiddleton
neilmiddleton / gist:5109447
Created March 7, 2013 16:38
class variables
class Person
attr gender
def male?
@gender == 'male'
end
end

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discussions around concrete examples, not handy-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style