Skip to content

Instantly share code, notes, and snippets.

View johnbeynon's full-sized avatar

John Beynon johnbeynon

View GitHub Profile
-----> DEPRECATIONS:
Runtime asset compilation is being removed on Sep. 18, 2013.
Builds will soon fail if assets fail to compile.
@johnbeynon
johnbeynon / gist:6460735
Created September 6, 2013 07:44
Heroku generated database.yml
<%
require 'cgi'
require 'uri'
begin
uri = URI.parse(ENV["DATABASE_URL"])
rescue URI::InvalidURIError
raise "Invalid DATABASE_URL"
end
@johnbeynon
johnbeynon / gist:6915478
Last active December 25, 2015 04:09
Devise strategy to bypass entering a password for development mode

This is a simple devise strategy that allows you to bypass the need to enter a password when a site is runnning in development mode.

lib\devise\strategies\development.rb

module Devise
  module Strategies
    class Development < Authenticatable
      def authenticate!
 resource = mapping.to.find_for_database_authentication(authentication_hash)
@johnbeynon
johnbeynon / gist:8306497
Created January 7, 2014 20:41
first pass at duplicating Philips Wake up light functionality
# Fade up Light from 0 to 80% over 30 minutes
time_to_take = 1800 # in seconds
increase_to_level = 80 # percent
number_of_steps = increase_to_level / 10
time_per_step = time_to_take / number_of_steps
0.upto(number_of_steps) do |loop_index|
level = loop_index * 10
puts "Increasing Light Level to #{level}%"
[2014-01-30T09:53:02+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-01-30T09:53:02+00:00] ERROR: service[postgresql] (postgresql::server_debian line 30) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /etc/init.d/postgresql restart ----
STDOUT: * Restarting PostgreSQL 9.3 database server
* The PostgreSQL server failed to start. Please check the log output:
2014-01-30 09:53:02 GMT FATAL: could not load server certificate file "server.crt": No such file or directory
...fail!
STDERR:
---- End output of /etc/init.d/postgresql restart ----
Ran /etc/init.d/postgresql restart returned 1
@johnbeynon
johnbeynon / gist:9322825
Created March 3, 2014 11:04
Travis YML
language: ruby
rvm:
- 2.0.0
cache: bundler
before_install:
- "psql -c 'create database <dbname>;' -U postgres"
- "psql -U postgres -q -d <dbname> -f db/structure.sql"
- "cp config/database.yml.travis config/database.yml"
env:
matrix:
@johnbeynon
johnbeynon / gist:9322859
Created March 3, 2014 11:06
before_deploy.sh
#!/usr/bin/env bash
set -e
echo "Running post Heroku deployment script"
echo "Installing Heroku toolbelt"
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
# You need to bundle if you want to be able to enabled maintenance mode.
# bundle

Keybase proof

I hereby claim:

  • I am johnbeynon on github.
  • I am johnbeynon (https://keybase.io/johnbeynon) on keybase.
  • I have a public key whose fingerprint is A5B4 D9BA 969A AE41 438B D180 4056 40E9 95A2 C093

To claim this, I am signing this object:

-----BEGIN PGP MESSAGE-----
Version: Keybase OpenPGP JS 0.0.1
Comment: https://keybase.io/crypto
wcBMA43lKB+8iCMcAQf+NAAyZWOxBIDmyH75KK9/m4h0Q1DETD/p2hEL0ZKJ8g2F
kJq4/UyQ1kEVA91tIgbMAmV5BWiY41HsldISiunwGeMXQBcPzINWEOScL9/pRB/T
V0ShCZr2sQCHDVX/asHsk2/dY3ur+YZ772yCCb6NFWvU5hyeTdGvvKfqixWLtKaW
aQQTMvdyhpZqbC5YDuM8HDk40gg+s+YtTo12KqPdCSyNdGwEJ+LbOKbOI37/semv
CR/RQCtHknf/0clBCxNQTJUy9tH6dI10YDtfguHOAZbMeZ2OB6OUPuwvqDARTTXk
kc3Or0AiOOtTXAtzw7Zmh2JWSHGbGgClC2MVnNEuDNLBFAH7uadqZFlMf43UCRcm
@johnbeynon
johnbeynon / backup_all_dbs.sh
Last active August 29, 2015 13:57
Backup commands for MySQL and Postgres - backs up all databases!
# backup_all_dbs.sh
# Expects ~/backups to exist
# Expects pg to be running on 127.0.0.1
# Expects mysql to be running on 127.0.0.1
# Expects mysql root user to have no password
# Expects zip to be available.
echo "Backing up local DBs"
pg_dumpall -h 127.0.0.1 > ~/backups/postgres.sql
mysqldump -u root --all-databases > ~/backups/mysql.sql