Skip to content

Instantly share code, notes, and snippets.

View sirbrillig's full-sized avatar

Payton Swick sirbrillig

View GitHub Profile
@lgsunnyvale
lgsunnyvale / gist:4229489
Created December 6, 2012 23:48 — forked from bruth/gist:2865951
Backbone Sync Queue
# Override `Backbone.ajax` to queue all requests.
# Cache Backbone ajax function, by default, just $.ajax
_ajax = Backbone.ajax
# Override Backbone.ajax to queue all requests to prevent
# lost updates.
Backbone.ajax = (options) ->
@ajax.queue options
@strukturedkaos
strukturedkaos / gist:3801641
Created September 28, 2012 19:17 — forked from jkassemi/gist:3797001
Select2.js capybara
def select2_select(text, options)
page.find("#s2id_#{options[:from]} a").click
page.all("ul.select2-results li").each do |e|
if e.text == text
e.click
return
end
end
end
@michaelcox
michaelcox / SpecRunner.js
Last active October 12, 2024 17:11
Browser Unit Testing with Backbone Mocha Chai and RequireJS
require.config({
baseUrl: '/backbone-tests/',
paths: {
'jquery' : '/app/libs/jquery',
'underscore' : '/app/libs/underscore',
'backbone' : '/app/libs/backbone',
'mocha' : 'libs/mocha',
'chai' : 'libs/chai',
'chai-jquery' : 'libs/chai-jquery',
'models' : '/app/models'
@RSpace
RSpace / feature.rb
Created August 15, 2012 19:55
Browser testing with Test::Unit, Capybara, Poltergeist and PhantomJS
class Feature < Test::Unit::TestCase
include Capybara::DSL, FactoryGirl::Syntax::Methods
def teardown
Capybara.reset_sessions!
Capybara.use_default_driver
end
add_teardown_hook do |context|
context.instance_eval do
@earthgecko
earthgecko / bash.generate.random.alphanumeric.string.sh
Last active April 24, 2025 05:26
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1
@patocallaghan
patocallaghan / css-triangle.scss
Created June 21, 2012 01:07
CSS Triangles SCSS Mixin #css #scss #triangle #mixin
//==== Simple SCSS mixin to create CSS triangles
//==== Example: @include css-triangle ("up", 10px, #fff);
@mixin css-triangle ($direction: "down", $size: 20px, $color: #000) {
width: 0;
height: 0;
border-left: $size solid #{setTriangleColor($direction, "left", $color)};
border-right: $size solid #{setTriangleColor($direction, "right", $color)};
border-bottom: $size solid #{setTriangleColor($direction, "bottom", $color)};
border-top: $size solid #{setTriangleColor($direction, "top", $color)};
}
@bruth
bruth / gist:2865951
Last active November 19, 2017 20:11
Backbone Sync Queue
# Reference Backbone ajax function
_ajax = Backbone.ajax
requestQueue = []
requestPending = false
sendRequest = (options, promise, trigger=true) ->
options = _.clone options
if trigger
requestPending = true
<?php
/**
* PHPUnit
*
* Copyright (c) 2001-2012, Sebastian Bergmann <[email protected]>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@steveclarke
steveclarke / capybara.md
Created April 10, 2012 17:32
RSpec Matchers

Capybara

save_and_open_page

Matchers

have_button(locator)
@badsyntax
badsyntax / timeago.js
Created March 26, 2012 13:06
Javascript date time ago
Ext.Date.fuzzy = function(time, local){
(!local) && (local = Date.now());
if (typeof time !== 'number' || typeof local !== 'number') {
return;
}
var
offset = Math.abs((local - time)/1000),