Skip to content

Instantly share code, notes, and snippets.

View jxson's full-sized avatar

Jason Campbell jxson

View GitHub Profile
@jxson
jxson / documentation-outline.md
Created February 28, 2012 19:53
Topic guide documentation outline

Introduction

A short bit about what this guide is and why its important

Overview

Should explain the goal of the document, and generally these should be included

  • details
  • cross-references
@jxson
jxson / gist:1840807
Created February 16, 2012 01:41 — forked from mikeal/gist:1840641
get a new/clean port with node.js
var portrange = 45032
function getPort (cb) {
var port = portrange
portrange += 1
var server = net.createServer()
server.listen(port, function (err) {
server.once('close', function () {
cb(port)
@jxson
jxson / README.md
Created February 10, 2012 00:18
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation

@jxson
jxson / bananas.rb
Created February 1, 2012 02:26
Using cucumber, capybara, and net/http to check dynamically injected content
Then /^I should see the API documentation$/ do
uri = URI.parse('http://api.spire.io')
request = Net::HTTP::Get.new(uri.request_uri)
request['Accept'] = 'text/html'
response = Net::HTTP.start(uri.host, uri.port) {|http|
http.request(request)
}
page.should have_css('.api-reference')
@jxson
jxson / HTML language
Created November 22, 2011 19:01 — forked from kornelski/HTML language
TextMate HTML language tweaked to support unqoted attributes
{ scopeName = 'text.html.basic';
firstLineMatch = '<!DOCTYPE|<(?i:html)|<\?(?i:php)';
fileTypes = ( 'html', 'htm', 'shtml', 'xhtml', 'phtml', 'php', 'inc', 'tmpl', 'tpl', 'ctp' );
foldingStartMarker = '(?x)
(<(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|li|form|dl)\b.*?>
|<!--(?!.*--\s*>)
|^<!--\ \#tminclude\ (?>.*?-->)$
|<\?(?:php)?.*\b(if|for(each)?|while)\b.+:
|\{\{?(if|foreach|capture|literal|foreach|php|section|strip)
|\{\s*($|\?>\s*$|//|/\*(.*\*/\s*$|(?!.*?\*/)))
@jxson
jxson / http-browserify-get.js
Created October 13, 2011 20:30
http-browserify example
http = require('http');
var options = {
host: 'localhost',
port: '1337',
path: '/',
// NOTE: Headers can't be set until after the xhr is opened
// https://github.com/substack/http-browserify
// headers: {
// 'Accept': 'application/json'
@jxson
jxson / vows_stub.js
Created October 13, 2011 18:48
Stub file for writing vows tests
var vows = require('vows')
, assert = require('assert')
;
vows.describe('Whatever').addBatch({
'top level context': {
topic: function(){
var foo = 'bar';
return foo;
// less.js, modernizer, and almost all dymanic content seems broken :(
var zombie = require("zombie")
, assert = require("assert")
;
var jxson = new zombie.Browser();
var darthburrit0 = new zombie.Browser();
var url = 'http://localhost:8080/simple-chat/index.html';
// var url = 'http://localhost:8080/stylesheets/master.less';
@jxson
jxson / .gitignore
Created October 6, 2011 06:03
Crop images with node
node_modules
@jxson
jxson / adding-the-messages-template.html
Created October 4, 2011 01:20
Example Chat Application
<script id="message" type="text/html">
<div class="message {{ type }}" id="{{ cssID }}">
<time datetime="{{ time }}">{{ humanTime }}</time>
<span class="name {{#isYou}} current-user {{/isYou}}">
{{ author }}:
</span>
<span class="body">{{ content }}</span>