Skip to content

Instantly share code, notes, and snippets.

View nruth's full-sized avatar

Nicholas Rutherford nruth

View GitHub Profile
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@nruth
nruth / gist:1049494
Created June 27, 2011 18:50
testing devise password recovery email with email_spec and capybara / rspec request spec
require 'spec_helper'
describe "member password recovery" do
# As a member who forgot my password
# I want to recover my site access easily
#
attr_accessor :current_email_address
specify "email recovery of a new password" do
member = make_activated_member
import Ember from 'ember';
import config from 'medify-bmat-grader/config/environment';
export function prefixRootUrl([href]) {
if (config.environment !== 'production') {
return `${config.rootURL}${href}`;
} else {
return href;
}
}
@nruth
nruth / image_helpers.rb
Created July 6, 2011 20:13
share test helper libs between rspec and cucumber in a pluggable fashion
# an example, showing how to load for rspec and conditionally load for cucumber
# lives in whichever dir you set the other file to load
module ImageStepHelpers
def page_should_contain_image_link_for(image)
page.should have_xpath(%Q(//img[@src="#{image.url}"]))
end
def image_data_from_file(image)
image_file_path = Rails.root.join image.image.path
@nruth
nruth / Vagrantfile
Created February 11, 2015 02:50
vagrant ubuntu 14.04 rbenv mysql for rails
Vagrant.configure(2) do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = 'ubuntu/trusty64'
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network "forwarded_port", guest: 3000, host: 3000
@nruth
nruth / redirector.js
Last active April 29, 2016 15:46
ember.js acceptance test window.location redirector abstraction service
import Ember from 'ember';
export default Ember.Service.extend({
redirectTo(href) {
window.location.href = href;
},
replace(href) {
window.location.replace(href);
},
reload() {
@nruth
nruth / routes.rb
Last active December 12, 2015 03:19
simple rails static page renderer
# last entry:
#static page routes
get '/home' => redirect('/')
root :to => 'static_pages#home'
get '*page', :to => 'static_pages#show', :constraints => {:page => %r{[\w\-\/]+}}
@nruth
nruth / Sitemap.rb
Last active December 12, 2015 03:19
basic rails sitemap generator
# -*- encoding : utf-8 -*-
class Sitemap
def self.static_view_templates
require 'fileutils'
template_paths = []
FileUtils.cd Rails.root.join 'app', 'views', 'static_pages' do
erb_html_files = File.join "**", "*.html.erb"
template_paths = Dir.glob(erb_html_files)
end
remove_html_erb!(template_paths)
@nruth
nruth / Makefile
Created April 9, 2012 14:24
gecode gcc makefile
all: send-more-money donald
# use git clean -f for make clean, but confirm action
define gitCLEAN
puts 'ARE YOU SURE (git clean -f) ? y/n'; \
puts %x(git clean -n); \
exec('git clean -f') if gets.chomp =~ /^y/i
endef
clean:
@nruth
nruth / gist:1377390
Created November 18, 2011 18:54
A poem about OTP
Old tired programmers() ->
obviously trusted prolog,
others tried perl.
Oft they pondered() ->
of teams problems,
of telcos pains.
Onward they plodded() ->
obscure to programmers,