Skip to content

Instantly share code, notes, and snippets.

View maxehmookau's full-sized avatar

Max Woolf maxehmookau

View GitHub Profile
class Customer
def self.active
get all customers where order total is above £100 this month
end
end
class CustomerTest
test 'get a list of all customers who have spent over £100 this month' do
create_list(:customer, 10, :spent_over_100_pounds)
create_list(:customer, 10, :spent_less_than_100_pounds)
assert_equal 10, Customer.active.size
end
end
"Max likes this"
"Max, Adam and Steve like this"
Is there a prebuilt function to decide which form of `like` to use?
{
"bold_folder_labels": true,
"color_scheme": "Packages/Theme - Spacegray/base16-ocean.dark.tmTheme",
"create_window_at_startup": false,
"default_line_ending": "unix",
"font_face": "Anonymous Pro",
"font_size": 15,
"ignored_packages":
[
"Theme - Flatland",
{
"featureType": "poi.park",
"stylers": [
{ "color": "#AEB364" }
]
},{
"featureType": "road",
"elementType": "geometry",
"stylers": [
@maxehmookau
maxehmookau / routes.rb
Last active August 29, 2015 14:08
DRY up routes using methods in routes.rb
Rails.application.routes.draw do
api_read_actions = [:index, :show]
api_resources = [:videos, :people, :collections]
api_resources.each do |api_resource|
resources api_resource, only: api_read_actions
end
end
@maxehmookau
maxehmookau / settings.json
Created October 30, 2014 10:01
My sublime settings
{
"bold_folder_labels": true,
"color_scheme": "Packages/Color Scheme - Default/Solarized (Dark).tmTheme",
"create_window_at_startup": false,
"default_line_ending": "unix",
"font_face": "Anonymous Pro",
"font_size": 18,
"ignored_packages":
[
"Theme - Flatland",

Keybase proof

I hereby claim:

  • I am maxehmookau on github.
  • I am maxw (https://keybase.io/maxw) on keybase.
  • I have a public key whose fingerprint is AF87 B45A 396D 80E6 3D83 B4CC 38EC 5C7C 4E61 2C87

To claim this, I am signing this object:

@maxehmookau
maxehmookau / NSNumber+SUBNumberAdditions.h
Created August 29, 2014 14:00
Objective-C Categories for Converting NSNumber containing military time to NSDate
#import <Foundation/Foundation.h>
@interface NSNumber (SUBNumberAdditions)
- (NSDate *)sub_DateFromMilitaryTime;
- (BOOL)sub_isValidMilitaryTime;
@end
@maxehmookau
maxehmookau / NSNumber+Additions.m
Created August 7, 2014 10:33
Convert military time to NSDate (NSNumber Category)
- (NSDate *)sub_DateFromMilitaryTime {
NSDate *newDate;
NSDateComponents *comps = [[NSDateComponents alloc] init];
[comps setMinute:[self intValue] % 100];
[comps setHour:floor(self.intValue / 100)];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
newDate = [gregorian dateFromComponents:comps];
return newDate;
}