Skip to content

Instantly share code, notes, and snippets.

View pete-otaqui's full-sized avatar

Pete Otaqui pete-otaqui

View GitHub Profile
@pete-otaqui
pete-otaqui / StandardSpider.rb
Created February 16, 2010 09:09
Prototype spider which uses 'bbc_standards' to test a whole website
# Prototype spider which uses 'bbc_standards' to test a whole website
require 'rubygems'
require 'anemone'
require 'bbc_standards'
require 'term/ansicolor'
class String
include Term::ANSIColor
end
{
"description" : "A schema describing API docs. Top-level object is the top level anonymous namespace",
"extends" : [ { "$ref" : "#.defs.namespace" } ],
"properties" : {
"typedefs" : {
"type" : "object",
"optional" : true,
"additionalProperties" : { "$ref" : "#.defs.typedef" }
}
},
#!/usr/bin/node
var fs = require('fs');
var sys = require('sys');
var schema = fs.readFileSync(process.argv[2], 'utf8');
var json = fs.readFileSync(process.argv[3], 'utf8');
schema = JSON.parse(schema);
{
"namespaces" : {
"glow" : {
"namespaces" : {
"dom" : {
"classes" : {
"NodeList" : {
"constructor" : {
"methods" : {
"aStaticMethod" : {
@pete-otaqui
pete-otaqui / app.js
Created September 9, 2010 04:32
Example node event emitter setup from neveraw.us
var pb = new PhoneBook('asdf.txt');
pb.on('error', function(error) {
console.log(error);
});
pb.on('data', function(data) {
console.log(data);
});
@mcrmfc
mcrmfc / VIM - Vertical Buffer Split
Last active September 25, 2015 06:38
VIM - My cheat sheet
search and replace
-------------------
s/foo/bar/g changes each 'foo' to 'bar' in the current line.
:%s/foo/bar/g changes each 'foo' to 'bar' in all lines.
:5,12s/foo/bar/g changes each 'foo' to 'bar' for all lines between line 5 and line 12.
:'a,'bs/foo/bar/g changes each 'foo' to 'bar' for all lines between marks a and b.
:.,$s/foo/bar/g changes each 'foo' to 'bar' for all lines between the current line (.) and the last line ($).
:.,+2s/foo/bar/g changes each 'foo' to 'bar' for the current line (.) and the two next lines (+2).
:%s is equivalent to :1,$s
@pete-otaqui
pete-otaqui / Gemfile
Created August 11, 2011 14:32
Capybara, Cucumber, Webdriver, Mechanize and SauceLabs ... whew!
source "http://rubygems.org"
gem "cucumber"
gem "capybara"
gem "capybara-webkit", :platforms => [:ruby], :require => false, :git => "git://github.com/thoughtbot/capybara-webkit.git"
gem "capybara-mechanize", :git => "git://github.com/jeroenvandijk/capybara-mechanize.git"
gem "rspec"
gem "rake"
@pete-otaqui
pete-otaqui / env.rb
Created September 15, 2011 15:48
env.rb for cucumber ... with fixtures in a mysql database
=begin
Environment variables you can set:
MHT_HOST=domain.com ... the host to test, default is www.mangahigh.com
MHT_DRIVER='mechanize' ... default capybara driver to use, valid values are:
mechanize,
celerity,
chrome,
culerity,
selenium,
@pete-otaqui
pete-otaqui / fake_console.js
Created September 22, 2011 08:59
Fake Firebug API, allows safe use of Firebug / Web Inspector commands without breaking IE
/**
* Create a fake console api, mimicing Firebug.
*/
(function(global) {
var noop = function(){};
if ( !global['console'] ) {
global.console = {
log : noop,
debug : noop,
@pete-otaqui
pete-otaqui / appendAt.jquery.js
Created October 1, 2011 20:23
jQuery plugin to append content at a specific or random index
jQuery.fn.appendAt = function( content, index ) {
this.each(function(i, item) {
var $content = $(content).clone();
if ( index === 0 ) {
$(item).prepend($content);
} else {
$content.insertAfter($(item).children().eq(index-1));
}
});