Skip to content

Instantly share code, notes, and snippets.

View nickcharlton's full-sized avatar
🐢
I'm swamped at the moment and will respond when I can!

Nick Charlton nickcharlton

🐢
I'm swamped at the moment and will respond when I can!
View GitHub Profile
@nickcharlton
nickcharlton / date_accessor.rb
Created July 16, 2015 07:10
An example of creating a custom accessor type to parse inputs.
#!/usr/bin/ruby
require 'date'
class Resource
def initialize(hash = {})
hash.each { |k, v| send("#{k}=", v) if respond_to?("#{k}=") }
end
class << self
$ bundle exec bin/run
dyld: lazy symbol binding failed: Symbol not found: _rb_str_new_static
Referenced from: /Users/nickcharlton/.gem/ruby/2.2.2/gems/json-1.8.3/lib/json/ext/parser.bundle
Expected in: flat namespace
dyld: Symbol not found: _rb_str_new_static
Referenced from: /Users/nickcharlton/.gem/ruby/2.2.2/gems/json-1.8.3/lib/json/ext/parser.bundle
Expected in: flat namespace
[1] 72256 trace trap bundle exec bin/run
% vagrant provision
The following berks command failed to execute:
/Users/nickcharlton/.gem/ruby/2.2.2/bin/berks --version --format json
The stdout and stderr are shown below:
stdout:
stderr: /Users/nickcharlton/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'berkshelf' (>= 0) among 84 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/nickcharlton/.vagrant.d/gems:/opt/vagrant/bin/../embedded/gems', execute `gem env` for more information
@nickcharlton
nickcharlton / Gemfile
Created February 17, 2016 14:09
List the currently available Vagrant boxes from boxes.io.
source "https://rubygems.org"
gem "atlas"
gem "table_print"
@nickcharlton
nickcharlton / postgres.sh
Created April 4, 2016 13:13
postgres.sh
#!/bin/bash
apt-get install -qy postgresql postgresql-contrib libpq-dev postgresql-9.3-postgis-scripts
# allow connections on the local network
cat << 'EOF' >> /etc/postgresql/9.3/main/pg_hba.conf
# Allow connections on the 192.168.*.* local/VM network
host all all 192.168.0.0/16 md5
host all all 172.16.0.0/12 md5
EOF
@nickcharlton
nickcharlton / database_import.rake
Created April 6, 2016 21:22
Import a named database dump into the current Rails environment
namespace :db do
desc "Import a given file into the database"
task :import, [:path] => :environment do |_t, args|
dump_path = args.path
connection_config = ActiveRecord::Base.connection_config
case connection_config[:adapter]
when "postgresql"
system("pg_restore --verbose --clean --no-acl --no-owner " \
"-d #{connection_config[:database]} #{dump_path}")
@nickcharlton
nickcharlton / mysql.sh
Created April 11, 2016 15:54
Create a local instance of MySQL for Vagrant which allows external connections.
#!/bin/bash
# set a root password of "vagrant"
debconf-set-selections <<< "mysql-server mysql-server/root_password password vagrant"
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password vagrant"
apt-get install -qy libmysqlclient-dev mysql-server-5.5
# enable listening on all addresses
sed -i.bak "s/bind-address\s*= 127.0.0.1/bind-address = 0.0.0.0/g" /etc/mysql/my.cnf
@nickcharlton
nickcharlton / new_bamboo_github_accounts.rb
Last active May 5, 2016 11:31
A quick script to write out a list of New Bamboo GitHub accounts.
require "octokit"
require "csv"
Octokit.configure do |c|
c.login = "nickcharlton"
c.password = ENV["HOMEBREW_GITHUB_API_TOKEN"]
end
Octokit.auto_paginate = true
@nickcharlton
nickcharlton / resolve_jenkins_dependencies.sh
Created September 8, 2016 04:31
Recursively resolve Jenkins dependencies.
#!/bin/bash
set -e
plugin_dir=~/.jenkins/plugins
installed=()
discovered_dependencies=()
dependencies_to_install=()
mkdir -p $plugin_dir
@nickcharlton
nickcharlton / debian.cfg
Created September 22, 2016 11:20
Preseed file for Debian 8
#
# Based upon: https://help.ubuntu.com/12.04/installation-guide/example-preseed.txt
#
# localisation
d-i debian-installer/locale string en_US.utf8
d-i console-keymaps-at/keymap select us
# networking
d-i netcfg/choose_interface select auto