Skip to content

Instantly share code, notes, and snippets.

@alext
alext / path_helpers.rb
Created May 9, 2012 15:32
Some path helpers for rspec request specs.
module PathHelpers
# Takes a URL path (with optional query string), and asserts that it matches the current URL.
def i_should_be_on(path_with_query, options = {})
expected = URI.parse(path_with_query)
current = URI.parse(current_url)
current.path.should == expected.path
unless options[:ignore_query]
Rack::Utils.parse_query(current.query).should == Rack::Utils.parse_query(expected.query)
end
@alext
alext / section_helper.rb
Created May 9, 2012 15:35
Section helper for rspec request specs
module SectionHelper
def selector_of_section(section_name)
case section_name
when 'recent podcasts'
[:css, 'ul.podcasts']
when /^the row containing "[\"]+"$/
[:xpath, "//*[.='#{$1}']/ancestor::tr"]
else
raise "Can't find mapping from \"#{section_name}\" to a section."
end
@alext
alext / field_matchers.rb
Created February 21, 2013 10:51
Field matchers
module FieldMatchers
def i_should_see_field(name, options = {})
field = find_field(name)
field.should_not be_nil
case options[:type]
when nil
when 'textarea'
field.tag_name.should == type
else
field.tag_name.should == 'input'
body {
background: #fff;
color: #000;
}
#pulls {
text-shadow: unset;
color: #000;
}
#!/usr/bin/perl -w
if( scalar @ARGV < 1) {
die "Usage $0 config_file\n";
}
my $channels_map_file = "$ENV{'HOME'}/.xmltv/supplement/tv_grab_uk_atlas/tv_grab_uk_atlas.map.channels.conf";
my %channels = ();
unless(open CHANNELS, "< $channels_map_file") {
print STDERR "Failed to open channels map - $channels_map_file : $!\n";
#!/usr/bin/env ruby
require 'rubygems'
require 'rexml/document'
require 'mysql2'
require 'date'
HOME_CONFIG = "#{ENV['HOME']}/.mythtv/config.xml"
ETC_CONFIG = "/etc/mythtv/config.xml"
if File.exist?(HOME_CONFIG)
@alext
alext / adjust_exif_date.rb
Created April 12, 2016 21:49
Script to adjust the EXIF date of an image file by a given offset in days.
#!/usr/bin/env ruby
require 'open3'
require 'time'
EXIF_DATE_FORMAT='%Y:%m:%d %H:%M:%S'
offset = ARGV[0].to_i
file_name = ARGV[1]
@alext
alext / aws_vpn_routes.rb
Created January 9, 2017 10:36
Add AWS IP ranges to vpn config file.
#!/usr/bin/env ruby
# This script outputs a series of lines that can be added to the [ipv4] section
# of a NetworkManager VPN config file (typically found in
# /etc/NetworkManager/system-connections/)
#
# ./aws_vpn_routes.rb | sudo tee -a /etc/NetworkManager/system-connections/<connection_name>
require 'net/http'
require 'json'
2017/01/23 11:25:50 [INFO] Terraform version: 0.8.4 a791ff09b29d063dd4b6da0cac04ad3b83c836f5
2017/01/23 11:25:50 [INFO] CLI args: []string{"/Users/alextomlins/tmp/tf_0.8.4/terraform", "apply"}
2017/01/23 11:25:50 [DEBUG] Detected home directory from env var: /Users/alextomlins
2017/01/23 11:25:50 [DEBUG] Detected home directory from env var: /Users/alextomlins
2017/01/23 11:25:50 [DEBUG] Attempting to open CLI config file: /Users/alextomlins/.terraformrc
2017/01/23 11:25:50 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2017/01/23 11:25:50 [DEBUG] Detected home directory from env var: /Users/alextomlins
2017/01/23 11:25:50 [DEBUG] No diff, not a noop
2017/01/23 11:25:50 [TRACE] Graph after step *terraform.PruneNoopTransformer:
2017/02/06 11:46:07 [INFO] Terraform version: 0.8.5 b4d477660b5abd20f2a70175460c9603797fada0
2017/02/06 11:46:07 [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply", "."}
2017/02/06 11:46:07 [DEBUG] Detected home directory from env var: /Users/alextomlins
2017/02/06 11:46:07 [DEBUG] Discovered plugin: pingdom = /usr/local/bin/terraform-provider-pingdom
2017/02/06 11:46:07 [DEBUG] Detected home directory from env var: /Users/alextomlins
2017/02/06 11:46:07 [DEBUG] Attempting to open CLI config file: /Users/alextomlins/.terraformrc
2017/02/06 11:46:07 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2017/02/06 11:46:07 [DEBUG] Detected home directory from env var: /Users/alextomlins
2017/02/06 11:46:07 [DEBUG] Checking resource noop: aws_iam_server_certificate.cert
2017/02/06 11:46:07 [DEBUG] No diff, not a noop