Skip to content

Instantly share code, notes, and snippets.

View dominicsayers's full-sized avatar
☣️
I'm back

Dominic Sayers dominicsayers

☣️
I'm back
View GitHub Profile
@dominicsayers
dominicsayers / schema_syntax_error.md
Created March 18, 2013 14:59
Syntax errors in ActiveRecord schema.rb caused by $\ = ','

If you get schema.rb:16: syntax error, unexpected ',' when you do a rake environment db:setup it may be because the ActiveRecord task that builds this file happens to use the Ruby print statement.

So if you have a default separator set up by using

$\ = ','

somewhere in your code that gets executed before a rake task (e.g. in the header of a class) then schema.rb will end up with stray commas interspersed with the code that gets generated.

Obviously this effect will depend on the default delimiter you've configured but if it's not whitespace, prepare for trouble.

@dominicsayers
dominicsayers / mongodb-recovery.md
Created April 16, 2013 09:35
Recover Mongodb on Ubuntu after an unclean shutdown
sudo -u mongodb rm /var/lib/mongodb/mongod.lock
sudo -u mongodb mongod --dbpath /var/lib/mongodb --repair
sudo start mongodb
@dominicsayers
dominicsayers / samba.md
Created April 21, 2013 20:52
Samba hocus pocus

The thing you keep forgetting? The thing that makes Samba actually work instead of being a teeth-grinding night of frustration?

sudo smbpasswd username

@dominicsayers
dominicsayers / git-branches.md
Created April 23, 2013 16:22
Working with git branches for dummies

Working with git branches

Starting work on your new branch

  1. cd path/to/myapp
  2. git checkout develop
  3. git pull
  4. git checkout -b feature/my-new-feature
@dominicsayers
dominicsayers / relationships.md
Last active December 19, 2015 06:09
Storing relationships in a relational database

Storing relationships in a relational database

Approach 1: least data, simplest schema

The simplest way to store bilateral relationships is in a relationships table, with the subject (party_a) of the relationship in one column and the counterparty (party_b) of the relationship in another.

Schema

Column Type Description
@dominicsayers
dominicsayers / gist:6185585
Last active December 20, 2015 19:48
Checking for double quotes in output strings using Aruba
Feature: Config
In order to configure Foreplay
As a CLI
I want to be as usable as possible
Scenario: Check configuration parameters - invalid parameter
When I run `foreplay check --invalid xyz`
Then the output should contain:
"""
ERROR: foreplay check was called with arguments ["--invalid", "xyz"]
@dominicsayers
dominicsayers / ubuntu-server-setup.md
Last active December 27, 2015 18:19
Basic setup of Ubuntu server

This is my personal memo for setting up new Ubuntu servers in my environment. It may not be appropriate for your environment but feel free to use it as a starting point.

During setup

  1. Accept all defaults except as listed here.
  2. For the machine name use the full name including the local domain, e.g. new-server.local.domain
  3. Add a user for all build tasks, name is Build, username is build
  4. Do not encrypt the home directory.
  5. Do not use LVM
@dominicsayers
dominicsayers / server-config.md
Last active January 2, 2016 08:09
Post-install server configuration Ubuntu Server 13.10 64-bit
  1. sudo su
  2. apt-get install ssh openssh-server
  3. pico /etc/network/interfaces
iface eth0 inet static
	address		192.168.1.99
	netmask		255.255.255.0
	network		192.168.1.0
	broadcast	192.168.1.255
This file has been truncated, but you can view the full file.
You are using WebMock 1.16.1. VCR 2.8.0 has been tested against WebMock >= 1.8.0, < 1.16, and you are using a newer version. If you experience VCR issues, consider downgrading WebMock as it may fix it.
/home/build/.rvm/gems/ruby-2.1.0@xendata/gems/rspec-core-2.14.7/lib/rspec/core/memoized_helpers.rb:199: [BUG] Segmentation fault at 0x007ffffe0abff8
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:9336 p:---- s:32697 e:002696 CFUNC :fetch
c:9335 p:0011 s:32693 e:002692 LAMBDA /home/build/.rvm/gems/ruby-2.1.0@xendata/gems/rspec-core-2.14.7/lib/rspec/core/memoized_helpers.rb:199 [FINISH]
c:9334 p:0007 s:32691 e:002690 LAMBDA /home/build/Development/Xenapto/xendata/spec/jobs/angel_list_spec.rb:64 [FINISH]
c:9333 p:0015 s:32689 e:002685 BLOCK /home/build/.rvm/gems/ruby-2.1.0@xendata/gems/rspec-core-2.14.7/lib/rspec/core/memoized_helpers.rb:199 [FINISH]
c:9332 p:---- s:32683 e:002682 CFUNC :fetch
@dominicsayers
dominicsayers / green-padlock-development.md
Last active January 26, 2016 16:47
Green padlock development with nginx

Your production web site is delivered over SSL and has a beautiful green padlock in your users' browsers. But your dev environment uses plain old HTTP, or maybe SSL with a self-signed certificate that your browser doesn't recognise.

That's OK, but you're missing out on some nice stuff. For instance, some browsers will warn you if you're delivering mixed content over SSL (like a link to an image that's on plain old HTTP). If you don't see this until you release then you're not doing your users any favors.

So here's how I got my dev environment to give me a green padlock while I'm writing code:

1. Register a dev domain

Domains are pretty cheap these days. I registered a new domain for my dev environment - let's call it myapp.systems