Skip to content

Instantly share code, notes, and snippets.

View sirbrillig's full-sized avatar

Payton Swick sirbrillig

View GitHub Profile
@sirbrillig
sirbrillig / Gruntfile
Created July 17, 2014 16:26
Grunt task to run node server with jQuery, Browserify, and Handlebars
var loadTasks = require( 'load-grunt-tasks' );
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
nodemon: {
dev: {
script: 'server.js',
@sirbrillig
sirbrillig / composer.json
Created June 19, 2015 17:53
WP_Mock do_action failure
{
"require-dev": {
"10up/wp_mock": "dev-master"
}
}
@sirbrillig
sirbrillig / gist:4206758
Created December 4, 2012 17:44
RSpec have_normal_content matcher to normalize text.
RSpec::Matchers.define :have_normal_content do |expected|
match do |actual|
actual.text.squish =~ Regexp.new(expected)
end
failure_message_for_should do |actual|
"expected content '#{expected}' in normalized text '#{actual.text.squish}'"
end
failure_message_for_should_not do |actual|
@sirbrillig
sirbrillig / have_link_to.rb
Last active October 13, 2015 13:59
RSpec have_link_to matcher
@sirbrillig
sirbrillig / application_controller.rb
Created January 7, 2013 02:54
Adding Users to a rails app using has_secure_password.
class ApplicationController < ActionController::Base
protect_from_forgery
private
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
helper_method :current_user
@sirbrillig
sirbrillig / gist:4499620
Created January 10, 2013 05:06
Overflow a CSS background-image.
#wrapper {
background-image: url("image.png");
width: 80px; /* the image width is 100px; */
padding-right: 20px;
margin-right: -20px;
}
@sirbrillig
sirbrillig / Rakefile
Last active December 11, 2015 04:28
Rake tasks for deploying middleman to github pages (inspired by http://stackoverflow.com/questions/11809180/middleman-and-github-pages)
desc "build website"
task :build do
system "rm -rf build/*"
system "middleman build"
puts "## Build complete"
puts "To deploy, see the deploy task."
puts <<-eos
## If this is your first deploy and the gh-pages branch does not exist, run the following:
@sirbrillig
sirbrillig / select2_helper.rb
Created March 6, 2013 04:47
Capybara select2 fill_in helper (for eg: autocomplete).
def fill_in_select2(selector, options={})
page.find(:css, "#s2id_#{selector} a").click
page.find(:css, ".select2-search input.select2-input").set options[:with]
page.find(:css, ".select2-result-label").click # Choose the first result
end
@mixin bleed($padding: $grid-padding, $sides: left right) {
@if $sides == 'all' {
margin: - $padding;
padding: $padding;
} @else {
@each $side in $sides {
margin-#{$side}: - $padding;
padding-#{$side}: $padding;
}
}
@sirbrillig
sirbrillig / Vagrantfile
Created April 17, 2013 17:06
Vagrantfile for Rackspace Ubuntu with Puppet
Vagrant.configure("2") do |config|
config.vm.box = "dummy"
config.ssh.private_key_path = "PRIVATE_KEY"
config.vm.provider :rackspace do |rs|
rs.username = "USER"
rs.api_key = "KEY"
rs.flavor = /512MB/
rs.image = /Ubuntu/