Skip to content

Instantly share code, notes, and snippets.

@agmcleod
agmcleod / Cucumber.yml
Created May 19, 2011 13:58
YAML cucumber file
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --color --tags ~@wip"
%>
default: "<%= std_opts %> features"
wip: "--tags @wip:3 --wip features"
rerun: "<%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip"
@agmcleod
agmcleod / gist:1038463
Created June 21, 2011 18:02
parse_zips.rb
# original version, took approximatley 27 minutes.
lines = []
File.open('zips-in.txt', 'r+') do |f|
f.each_line { |l| lines << l unless lines.include? l }
end
File.open('zips-out.csv', 'w+') do |f|
lines.each do |l|
f.write "#{l.split(',').join(' - ')},#{l}"
@agmcleod
agmcleod / gist:1060926
Created July 2, 2011 15:54
test_sort.rb
require 'benchmark'
class Student
attr_accessor :name, :age
def initialize(args)
args.each do |k, v|
send("#{k}=".to_sym, v)
end
end
@agmcleod
agmcleod / add_doc_steps.rb
Created July 29, 2011 23:12
There's got to be a better way to do this cucumber step
# Document being an active record model, and the test_data method returning a string.
# Is there a smarter way to organize this? Should i just use a local method in this step def file?
When /^I copy and paste a document$/ do
fill_in "content", Document.test_data
end
# used to quickly build a sql where condition to copy and paste.
"1
2
3
4
5
6
7
8
9".split(/\n/).collect { |c| "id='#{c}'" }.join(' OR ')
@agmcleod
agmcleod / after.js
Created August 16, 2011 16:55
Ajax CSRF issue
$.ajax({
url: '/combat_instance',
type: 'post',
beforeSend: function(jqXHR, settings) {
jqXHR.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
},
success: function(data) {
Game.CombatInstance.parseCreateData(data);
}
});
@agmcleod
agmcleod / model.php
Created September 6, 2011 15:20
Model base class
<?php
class Model
{
private $id;
private $data = Array();
private $fieldNames = Array();
public static function find($id)
{
$tn = self::getTableName();
@agmcleod
agmcleod / gist:1201092
Created September 7, 2011 16:53
markdown example
# AB Testing in pagetorrent
## Limitations of Test and target
- Cross domain requests
- Can cause tracking issues when clicking outbound links. The request doesnt finish before the link does.
- Difficulty tracking periodical tests.
- Expensive license
## Pluses of Test and target
@agmcleod
agmcleod / simplecssreset.css
Created September 12, 2011 15:35
My own css reset
* { margin:0;padding:0;}
h1,h2,h3,h4,h5,p,li,a { font-size:12px;font-weight:normal;}
button, img { border:0; }
body {
font-family:Arial, sans-serif;
}
@agmcleod
agmcleod / example.scss
Created September 12, 2011 15:56
SCSS Optimization
@mixin content-middle {
width:1100px;
margin:0 auto;
}
.top {
height:123px;
background-color:#fff;
.content {
@include content-middle;