Skip to content

Instantly share code, notes, and snippets.

View chalkers's full-sized avatar

Andrew Chalkley chalkers

  • Portland, OR, USA
View GitHub Profile
if (!navigator.geolocation) {
navigator.geolocation = (function (window) {
function reloadGeoIP(callback) {
// NOTE: for some reason, chaging the url is *allowed* with this service. Useful, but random
var geourl = 'http://j.maxmind.com/app/geoip.js_' + Math.random(),
iframe = document.createElement('iframe'),
doc, win;
iframe.style.display = 'none';
Scenario: Create valid User
Given I have no users
And I am on the users page
When I follow "New User"
And I fill in "First Name" with "Paul"
And I fill in "Last Name" with "Ketelle"
And I fill in "Username" with "ketellep"
And I fill in "Email" with "paul@white-agency.co.uk"
And I fill in "Password" with "pk1"
And I fill in "Password Confirmation" with "pk1"
And I unselect "Evolution" from "Tags"
Scenario: Ordering
And I follow "Archive"
Then I should see the following div with id archive results:
|Article Evolution and Biology Title TAGGED: BIOLOGY, EVOLUTION|
|Article Biology Only Title TAGGED: BIOLOGY |
|Article Evolution Only Title TAGGED: EVOLUTION |
When I follow "Article Biology Only Title"
And I fill in "Content" with "This comment should be long enough!"
And I press "Create Comment"
And I follow "Archive"
module Rack
class UDPLoggerThingy
def initialize app, options = { }
@app = app
end
def call env
status, headers, body = @app.call(env)
#Do shit here
#http://rack.rubyforge.org/doc/classes/Rack/Request.html
validates_format_of :email, :with => /^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i
validates_format_of :website, :with => /^http:\/\//
rails testing_deployed_app
cd testing_deployed_app
ruby script/generate cucumber --rspec --capybara
#In features/support/env.rb add
Capybara.current_driver = :selenium
Capybara.app_host = 'http://news.bbc.o.uk'
rake db:migrate
@chalkers
chalkers / HTMLToMarkdown.js
Created February 22, 2011 06:12
Pass in a jQuery representation of an element ($container) you get markdown out.
function htmlToMarkdown($container) {
var $clone = $container.clone();
$("*",$clone).removeAttr("name").removeAttr("title").removeAttr("id")
var html = $clone.html();
html = standardiseHTML(html);
html = html.replace(/<a [^h]*href=["']([^"']*)["'][^>]*>([^<]*)<\/a>/gi, " [$2]($1)");
html = html.replace(/<em[^>]*>([^<]*)<\/em>/gi,"*$1*");
html = html.replace(/<strong[^>]*>([^<]*)<\/strong>/gi,"**$1**");
html = html.replace(/<i[^>]*>([^<]*)<\/i>/gi,"*$1*");
html = html.replace(/<b[^>]*>([^<]*)<\/b>/gi,"**$1**");
@chalkers
chalkers / gist:1435273
Created December 5, 2011 20:47
Face Detection
//Have a UIImage *image
NSDictionary *detectorOptions = [[NSDictionary alloc] initWithObjectsAndKeys:CIDetectorAccuracyHigh, CIDetectorAccuracy, nil];
CIDetector *faceDetector = [CIDetector detectorOfType:CIDetectorTypeFace context:nil options:detectorOptions];
CIImage *ciImage = [CIImage imageWithCGImage:[image CGImage]];
NSArray *features = [faceDetector featuresInImage:ciImage];
@chalkers
chalkers / basic_library.ino
Last active December 19, 2015 18:38
Which is better?
#include <DigitalPin.h>
DigitalPin forward(13);
DigitalPin backward(12);
void setup(){
}
void loop() {
backward.off();