Skip to content

Instantly share code, notes, and snippets.

View adamcooke's full-sized avatar

Adam Cooke adamcooke

View GitHub Profile
@adamcooke
adamcooke / ghost.conf
Created October 15, 2013 09:12
Ghost Upstart Configuration File
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [016
respawn
exec sh -c 'cd /opt/ghost/app && npm start'
// Create a new layer which is the width of the device and with a heigh
// of 0.5px.
CALayer *topBorder = [CALayer layer];
topBorder.frame = CGRectMake(0.0f, 0.0f, self.view.frame.size.width, 0.5f);
// Set the background colour of the new layer to the colour you wish to
// use for the border.
topBorder.backgroundColor = [[UIColor blueColor] CGColor];
// Add the later to the tab bar's existing layer
@adamcooke
adamcooke / SPAppDelegate.m
Created September 12, 2014 22:52
This shows how an iOS device registers itself with the Sirportly API for Push Notifications (which go via APNS Proxy).
// When a user accepts push notifications on the device, this method is called and it makes an API request
// to the Sirportly API with the token.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSString *deviceTokenAsString = [NSString stringWithFormat:@"%@", deviceToken];
deviceTokenAsString = [deviceTokenAsString stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
deviceTokenAsString = [deviceTokenAsString stringByReplacingOccurrencesOfString:@" " withString:@""];
NSDictionary *params = @{@"device_type": @"iphone", @"identifier": deviceTokenAsString};
[[SPAPIClient sharedClient] makeRequest:@"mobile/register" params:params completion:^(SPAPIResponse *response) {
// Done - no need to actually do anything.

Keybase proof

I hereby claim:

  • I am adamcooke on github.
  • I am adamcooke (https://keybase.io/adamcooke) on keybase.
  • I have a public key whose fingerprint is 4A56 6CF7 DB1B 01B1 55EE 6911 D182 55F5 F117 FE7B

To claim this, I am signing this object:

@adamcooke
adamcooke / dsl.rb
Created November 7, 2014 15:20
The complete code from my DSL tutorial at http://blog.atechmedia.com/ruby-dsls-for-fun/
class AddressBook
def contacts
@contacts ||= []
end
def self.load_from_path(path)
# Create a new AddressBook instance
address_book = self.new
# Create a new AddressBookDSL instance
@adamcooke
adamcooke / router-config.txt
Created January 26, 2015 11:47
Full EdgeRouter Config for my home network
firewall {
all-ping enable
broadcast-ping disable
group {
ipv6-network-group ipv6-allowed-networks {
ipv6-network 2a00:67a0:a:6::/64
ipv6-network 2a00:67a0:a:2::138/128
ipv6-network 2a00:67a0:a:13::/64
}
network-group allowed-networks {
@adamcooke
adamcooke / unicorn.rb
Created January 26, 2015 17:44
Viaduct-friendly unicorn.rb
#
# This is a unicorn configuration file which works well when deploying
# Rails applications to Viaduct. It allows a certain level of configuration of
# your Unicorn processes using environment variables. This should be placed
# in config/unicorn.rb within your application.
#
# Last modified: 2015-25-01
#
app_root = File.expand_path('../../', __FILE__)
< HTTP/1.1 404 Not Found
< Date: Tue, 03 Feb 2015 21:26:29 GMT
< Vary: Accept-Encoding
< Content-Length: 298
< Content-Type: text/html; charset=iso-8859-1
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>200 OK</title>
</head><body>
ingredients
-----------
150g softened butter (salted if poss, otherwise add a extra 1/4 teasoon of talk)
110g light brown muscovado sugar
50g granulated sugar
2tsp vanilla extract
1 large egg
225g plain flour
1/2 tsp bicarb of soda
require 'bundler/setup'
require 'active_record'
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
ActiveRecord::Migration.create_table :users do |t|
t.string :first_name, :last_name
t.timestamps :null => false
end
class User < ActiveRecord::Base
end