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 / 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)
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 / 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
@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 / 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 / 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 {
$ ~/ nslookup
> server 8.8.8.8
Default server: 8.8.8.8
Address: 8.8.8.8#53
> o localhost
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: o.dev.kyanmedia.net
LOG: could not bind IPv4 socket: Can't assign requested address
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
WARNING: could not create listen socket for "localhost"
FATAL: could not create any TCP/IP sockets
class Array
def foo
puts self
end
end
class Bar < ActiveRecord::Base
...blah
end
Writing is hard, so do it.
==========================
Over the last few months I've been working on something that I wouldn't have seen myself doing at any point in my life, and that's the task of writing a book. I'm not talking about a 'Janet & John' novel, or some sort of 'Fifty Shades of Grey' sort of affair, but a proper printed dead tree, trip over it, technical book.
It all started back in May/June time when I was approached by a good friend at [Heroku](http://www.heroku.com), who had been approached in turn by [O'Reilly](http://www.oreilly.com), to produce a book about the platform and some rough ideas for what sort of book might be relevant and saleable. At the end of a fairly lengthy process it ended up that I was the author, had a contract in my hand and a schedule to try and stick to.
Cripes
## Getting started