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 / 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

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@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)
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 / 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
@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 / require-js-dep-arrays-vs-node-style.coffee
Created November 25, 2013 23:41
Managing RequireJS Dependency Arrays
## Managing RequireJS Dependency Arrays
define ['jQuery','Backbone','Handlebars','AModel'], ($, _, Backbone, HB, AModel) ->
...
## VERSUS Node style requires..
define (require) ->
$ = require 'jQuery'
Backbone = require 'Backbone'
@dan-palmer
dan-palmer / Gruntfile.coffee
Last active December 29, 2015 08:59
Example Grunt File for Watching & Compiling .coffee files in a project
sourceFiles = [ '*.coffee', 'models/*.coffee', 'views/*.coffee' ]
fullPathSourceFiles = sourceFiles.map (f) -> "app/coffee/" + f
fullPathSpecFiles = sourceFiles.map (f) -> "specs/coffee/" + f
module.exports = (grunt) ->
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
watch:
coffee:
files: fullPathSourceFiles.concat(fullPathSpecFiles)
<html>
<head>
<meta charset="utf-8">
<title>Base</title>
<!-- Styles -->
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.2.2/css/bootstrap.css"></link>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.2.2/css/bootstrap-responsive.css"></link>
(function() {
var root = this;
var BackboneMock = (function() {
if(typeof Backbone === 'undefined') {
throw '"Backbone" is undefined, make sure you have loaded ' +
'backbone.js before using this mock utility';
}
// Override Backbone.sync
// because we want to mock the requests