Skip to content

Instantly share code, notes, and snippets.

View newtriks's full-sized avatar

Simon Bailey newtriks

View GitHub Profile
@JaapRood
JaapRood / gist:cc8fe4533d45508f3f51
Last active August 29, 2015 14:05
A way to use AmpersandState and React together a bit more easily by mixing in Backbone's Event
// Not tested, but the main gist of glueing ampersand state and react components together well. The actual mixin I use in production is slightly more eleborate (handling the stopping of listening and rebinding through the component's lifecycle), but the main idea is there.
var Events = require('backbone-events-standalone'),
React = require('react'),
State = require('ampersand-state');
var PostModel = State.extend({
props: {
title: 'string',
body: 'string'
@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
@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";
@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.
#
@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" />
@aroop
aroop / GenerateImageThumbnailsJob.rb
Created February 1, 2012 07:45
Dragonfly image processor
class GenerateImageThumbnailsJob < Struct.new(:photo_id)
def perform
photo = Photo.find(photo_id)
photo.medium_image = photo.image.thumb('940x600')
photo.large_image = photo.image.thumb('450x')
photo.small_image = photo.image.thumb('172x167#c')
photo.save
end
@jurikern
jurikern / gist:4473824
Last active December 10, 2015 18:18
How update rbenv(ruby-build) with ruby versions list on MAC OS X.
before:
command: rbenv install 1.9.3-p362
output: ruby-build: definition not found: 1.9.3-p362
hack:
command: brew unlink ruby-build
output: Unlinking /usr/local/Cellar/ruby-build/20121120... 4 links removed
command: brew update
@amscotti
amscotti / server.js
Last active December 15, 2015 09:09
Proxy server for working with Yeoman and a REST API. Install http-proxy by running 'npm install http-proxy' or add to your package.json and run 'npm install'
var httpProxy = require('http-proxy'),
staticDir = 'app',
apiHost = '<Your API Host>',
apiPort = 80,
apiPath = '/api';
var proxy = new httpProxy.RoutingProxy();
connect()
.use(connect.logger("dev"))
.use(function (req, res, next) {