Skip to content

Instantly share code, notes, and snippets.

View moofish32's full-sized avatar

Mike Cowgill moofish32

View GitHub Profile

Commands examples

If the namespace is not used then the commands will perform on top of the default database. bundle exec rake db:create bundle exec rake db:migrate

By using the namespace we are going to use all the configuration for our alternate DB. bundle exec rake store:db:create bundle exec rake store:db:migrate

require 'active_support/core_ext'
require 'rails/all'
class Helpers
def self.map_type type
case type
when /boolean/
'bool'
when /java.lang.int/
'int32'
casper.incTestNumber = () =>
@count ?= 0
++@count
casper.setOddzContext = (ctx) =>
@oddzCtx = ctx
casper.getOddzContext = () =>
@oddzCtx
@moofish32
moofish32 / dnsmasq_setup.sh
Last active August 29, 2015 14:23
DNSMASQ Setup
#!/usr/env/bin sh
brew install dnsmasq;
cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf;
sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons;
sudo chown root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist;
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist;
sed -i.bak '/#address=\/double-click\.net\/127\.0\.0\.1/a\
address=/bspot.dev/'$(boot2docker ip) /usr/local/etc/dnsmasq.conf;
sudo launchctl stop homebrew.mxcl.dnsmasq;
@moofish32
moofish32 / dnsmasq_docker.sh
Created June 30, 2015 16:54
DNSMASQ with Docker
#!/usr/env/bin sh
brew install dnsmasq;
cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf;
sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons;
sudo chown root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist;
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist;
sed -i.bak '/#address=\/double-click\.net\/127\.0\.0\.1/a\
address=/docker.dev/'$(boot2docker ip) /usr/local/etc/dnsmasq.conf;
sudo launchctl stop homebrew.mxcl.dnsmasq;
@moofish32
moofish32 / boot2docker_dns_fix.sh
Created June 30, 2015 22:34
Boot2Docker Fix My DNS!
DOCKER_BRIDGE=`boot2docker ssh ifconfig docker0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
echo "Setting docker dns to the docker bridge @ $DOCKER_BRIDGE"
boot2docker ssh sudo "ash -c \"echo EXTRA_ARGS=\'--dns $DOCKER_BRIDGE --dns $(scutil --dns | awk -F ': ' '/nameserver/{print $2}' | head -1) --dns-search service.consul\' > /var/lib/boot2docker/profile\""
boot2docker restart
echo "... b2d restarted."
@moofish32
moofish32 / ubuntu_init.sh
Created October 13, 2015 16:41
init script for an ubuntu box
fancy_echo() {
printf "\n%b\n" "$1"
}
install_if_needed() {
local package="$1"
if [ $(dpkg-query -W -f='${Status}' "$package" 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
sudo aptitude install -y "$package";
-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: GPGTools - https://gpgtools.org
mQINBFYwAecBEADa6rlfrN6hLwJXeIjuRGj+E8KknKCIRo6rymlOmh9x9lHCDGPY
OVVzVj/+ETD52ZdPEwg8oQvwmy53dAbQJgVyFnMdE71dkBYrYkKf7HpKf40eu26O
vbx8QC0ZOY52HipwnIm1lgs3lYxo1lXoPNvjFkPkkLgur+Wr59q5rI+cTks9n8Y9
ymHyHgulSyA+RDz/rXeaCt5AiwN5JJHoQgRW/QvsMxmVSOTM0uBMg23P69kr6/Vl
ypW37KkanLTcvDDEfckbeJvrxFAtmUROGCoWwZWSVnFTMRjAxOJSfrUurZp0Af0G
xGhjy9htP5cUgAk1VtSdBS976w0hRz3jM4Ag7U4EPJ5GCNOo3RW7jc5ac5ldpXjW
PhYiM9TO/3uyFTsljz9B/wlgirq5kcWzpCPc8Ker2Pg22yjEZcI1oSXD4aZ98rDG
@moofish32
moofish32 / jdbc-1.3.5.stacktrace
Created January 15, 2014 20:19
Stacktrace for connection timeout issue with jdbc postgres
2014-01-15 17:48:24.040 F [9936:RubyThread-258: <redacted>/shared/bundle/jruby/1.9/gems/puma-2.7.1-java/lib/puma/server.rb:292] [[]] Rails --
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `wait_poll'
org/jruby/RubyKernel.java:1519:in `loop'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in `wait_poll'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:136:in `poll'
/opt/ruby/jruby-1.7.8/lib/ruby/1.9/monitor.rb:211:in `mon_synchronize'
/opt/ruby/jruby-1.7.8/lib/ruby/1.9/monitor.rb:210:in `mon_synchronize'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:146:in `synchronize'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:134:in `poll'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:423:in `acquire_connection'
@moofish32
moofish32 / Dockerfile
Created June 27, 2015 04:16
Slim JRUBY 1.7 using Alpine Linux and open JDK 8
FROM alpine:3.2
ENV JRE=jre1.8.0_60 \
JAVA_HOME=/opt/jre \
JRUBY_VERSION=1.7.20.1 \
JRUBY_SHA1=6a6e701a3a5769ec5d53a78660521c37da36e41f
# That's an 1.8.0_60 JRE from OpenJDK.net
# Courtesy to https://github.com/frol/docker-alpine-oraclejdk8 from where
# the setup of glibc is borrowed
RUN apk add --update wget bash ca-certificates && \
cd /tmp && \