Skip to content

Instantly share code, notes, and snippets.

View dan-palmer's full-sized avatar
👨‍💻

Dan Palmer dan-palmer

👨‍💻
View GitHub Profile
@dan-palmer
dan-palmer / gist:2d8de3109bcb767a51e4
Last active August 29, 2015 14:01
qmake config - g++ version 4.8.2 (was required for capybara webkit v1.1.0)
# Found at: /usr/local/Cellar/qt/4.8.6/mkspecs/common/g++-macx.conf
#
# Qmake configuration for the GNU C++ compiler on Mac OS X
#
# Before making changes to this file, please read the comment in
# gcc-base.conf, to make sure the change goes in the right place.
#
# To verify that your change has the desired effect on the final configuration
# you can use the manual test in tests/manual/mkspecs.
#
@dan-palmer
dan-palmer / sidekiq_options_rspec_matcher.rb
Created August 11, 2014 19:27
Sidekiq Options Matcher for RSpec
RSpec::Matchers.define :have_sidekiq_options do |options|
match do |actual|
description { "has correct sidekiq options" }
options.each do |key,value|
#sidekiq options have stringified keys
break false unless actual.sidekiq_options_hash[key.to_s] == value
end
end
end
require 'rails_helper'
feature 'Confirmation Group Payment With Remission', type: :feature do
attr_reader :claim, :recipients, :email, :body
before :all do
@claim = create :claim, :group_payment_with_remission
@recipients = ["me@example.com"]
@email = BaseMailer.confirmation_email(claim, recipients).deliver_now
@body = email.parts.first.body.raw_source
@dan-palmer
dan-palmer / fizzbuzz.ex
Created May 31, 2015 00:54
Elixir FizzBuzz
defmodule FizzBuzz do
for {word, remainder} <- [{"FizzBuzz", 15}, {"Fizz", 3}, {"Buzz", 5}] do
def compute(num) when rem(num, unquote(remainder)) == 0, do: unquote(word)
end
def compute(num), do: num
end
1..100 |> Enum.map(&FizzBuzz.compute/1)

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@dan-palmer
dan-palmer / weekday_fake_alert_cycle.rb
Last active August 29, 2015 14:23
Repeating weekday incident SMS alert that triggers inbetween work hours.
require 'rubygems'
require 'active_support/time'
require 'clockwork'
require 'twilio-ruby'
require 'logger'
class WeekdayTimeKeeper
START_WORK_DAY = 10.hours.freeze
END_WORK_DAY = 17.hours.freeze
@dan-palmer
dan-palmer / rabbit_mq_connection_test.rb
Last active August 29, 2015 14:23
Testing a connection to Rabbit MQ
session = Bunny.new(
Sneakers::CONFIG[:amqp],
heartbeat: Sneakers::CONFIG[:heartbeat],
vhost: Sneakers::CONFIG[:vhost])
session.connected? # => false
session.start # connects to rabbit
session.connected? # => true
session.close # closes the connection
session.connected? # => false
@dan-palmer
dan-palmer / mysql-table-sizes-for-db.sql
Created July 10, 2012 09:27
Get mysql table sizes for a particular database
SELECT TABLE_NAME, table_rows, data_length, index_length,
round(((data_length + index_length) / 1024 / 1024),2) "Size in MB"
FROM information_schema.TABLES WHERE table_schema = "*DATABASE_NAME*";
@dan-palmer
dan-palmer / bash_profile
Created July 10, 2012 09:50
bash profile stuff
export CLICOLOR=1 # colour stuff
export LSCOLORS=GxFxCxDxBxegedabagaced
alias ls='ls -GFahlrt'
alias updatelocate='sudo /usr/libexec/locate.updatedb'
export PATH="/usr/local/mysql/bin:$PATH"
export HISTCONTROL=ignoreboth:erasedups # no duplicate entries
shopt -s histappend # append history file
@dan-palmer
dan-palmer / mbpr-eclipse-hack
Created July 18, 2012 21:46
Fix Eclipse For MacBook Retina
Do "Show package contents" on the Eclipse.app.
Edit Contents/Info.plist.
Just above:
</dict>
</plist>
Place this: