Skip to content

Instantly share code, notes, and snippets.

View newtriks's full-sized avatar

Simon Bailey newtriks

View GitHub Profile
@jnunemaker
jnunemaker / gist:217362
Created October 24, 2009 04:07 — forked from lukesutton/gist:107966
example of warden with sinatra
Warden::Manager.serialize_into_session{|user| user.id }
Warden::Manager.serialize_from_session{|id| User.get(id) }
Warden::Manager.before_failure do |env,opts|
# Sinatra is very sensitive to the request method
# since authentication could fail on any type of method, we need
# to set it for the failure app so it is routed to the correct block
env['REQUEST_METHOD'] = "POST"
end
@davist11
davist11 / Fancy File Inputs.js
Created October 25, 2010 21:32
Fancy File Inputs
var SITE = SITE || {};
SITE.fileInputs = function() {
var $this = $(this),
$val = $this.val(),
valArray = $val.split('\\'),
newVal = valArray[valArray.length-1],
$button = $this.siblings('.button'),
$fakeFile = $this.siblings('.file-holder');
if(newVal !== '') {
@fcurella
fcurella / IterableCollection.js
Created January 9, 2011 18:06
A Backbone.js collection class with utility methods for iterating and picking
IterableCollection = Backbone.Collection.extend({
initialize: function() {
//_.bindAll(this, )
this._resetIndexes();
},
_resetIndexes: function() {
this.currentIndex = 0;
this.hasSelection = false;
},
parse: function(response) {
@wheresalice
wheresalice / gist:889119
Created March 27, 2011 10:50
Arduino Webclient with static IPs - connects to Sinatra with a ping, should get a pong back
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1,3 };
byte server[] = { 192,168,1,2 };
String request = "GET /ping?q=123 HTTP/1.0";
class ApplicationController < ActionController::Base
...
# FORCE to implement content_for in controller
def view_context
super.tap do |view|
(@_content_for || {}).each do |name,content|
view.content_for name, content
end
end
end
@Stray
Stray / ExampleUsage.as
Created July 5, 2011 11:39
Fluent filter for a collection of users
requiredUsers = new UserDataVOFilter(allUsers)
.onlyManagers()
.withCompanyKey(3)
.withStatus(UserStatus.STAFF)
.data;
module Jekyll
class Pagination < Generator
# This generator is safe from arbitrary code execution.
safe true
# Generate paginated pages if necessary.
#
# site - The Site.
#
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@devboy
devboy / BlueForestDev.xml
Created November 2, 2011 18:21
BlueForest for IDEA11
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="BlueForestDev" version="1" parent_scheme="Default">
<option name="LINE_SPACING" value="1.1" />
<option name="EDITOR_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Menlo" />
<colors>
<option name="ADDED_LINES_COLOR" value="8080" />
<option name="ANNOTATIONS_COLOR" value="8080ff" />
<option name="ANNOTATIONS_MERGED_COLOR" value="80ff80" />
<option name="CARET_COLOR" value="ffffff" />
@gcoop
gcoop / qunit-runner.js
Created January 10, 2012 10:42
QUnit runner using PhantomJS.js
//
// Runs a folder of tests or a single test, using QUnit and outputs a JUnit xml file ready for sweet integration with your CI server.
//
// @usage
// DISPLAY=:0 phantomjs qunit-runner.js --qunit qunit.js --tests tests-foler/ --package package.json --junit qunit-results.xml
//
// package.json is a common JS package file which contains a list of files that need to be loaded before the tests are run. In this instance
// the package.json lists the files for a JS SDK, that gets loaded and then the tests test the SDK.
//
// Designed to run via PhantomJS.