Skip to content

Instantly share code, notes, and snippets.

@boy-jer
boy-jer / pageview.js.coffee
Created August 25, 2011 04:34 — forked from bradphelan/pageview.js.coffee
backbone based mobile page model
#=require haml
#=require backbone
class PageView extends Backbone.View
tag: "div"
class: "page"
classes: ->
[]
@boy-jer
boy-jer / github_tree_slider.js
Created August 25, 2011 12:32 — forked from ryanb/github_tree_slider.js
This is how GitHub's new AJAX file browser works.
GitHub.TreeSlider = function () {
if (window.history && window.history.pushState) {
function a() {
if (e.sliding) {
e.sliding = false;
$(".frame-right").hide();
$(".frame-loading:visible").removeClass("frame-loading")
}
}
if (!($("#slider").length == 0 || !GitHub.shouldSlide)) if (!navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
@boy-jer
boy-jer / rbenv-install-system-wide.sh
Created September 23, 2011 13:56
rbenv install and system wide install on Ubuntu 10.04 LTS.
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Add rbenv to the path:
@boy-jer
boy-jer / user.json.rabl_spec.rb
Created April 3, 2012 19:12 — forked from wulftone/user.json.rabl_spec.rb
Isolated Rabl Specs
# user.json.rabl_spec.rb
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..'))
$: << File.join(APP_ROOT, 'spec/support') # for my spec helpers
$: << File.join(APP_ROOT, 'config/initializers') # for rabl_init.rb
require 'my_spec_mocks'
require 'rabl'
require 'rabl_init'
# We need to fool rabl into thinking we are running rails.
# All rabl wants is the root path to help in finding templates.
<br>
var stickywidth = 200; // width of sticky note (can't be less than 200)<br>
var stickyheight = 200; // height of sticky note (can't be less than 200)<br>
var max_notes = 500; // maximum number of notes one can store<br>
var allowed_tags = '<br /><br><ol></ol><ul></ul><li></li><strong></strong><i></i>';<br>
var html5sticky = {};<br>
var note_index = 0;<br>
// add a note <br>
//we need to modify this to work as repin a note <br.
html5sticky.addNote = function(){<br>
@boy-jer
boy-jer / gist:2478384
Created April 24, 2012 09:39 — forked from dhh/gist:1014971
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@boy-jer
boy-jer / active_model_serializers.rb
Created May 16, 2012 11:09 — forked from benedikt/active_model_serializers.rb
Makes mongoid and active_model_serializers play nicely together
# config/initializers/active_model_serializers.rb
Mongoid::Document.send(:include, ActiveModel::SerializerSupport)
Mongoid::Criteria.delegate(:active_model_serializer, :to => :to_a)
@boy-jer
boy-jer / 0_app.rb
Created May 22, 2012 16:54 — forked from wycats/0_app.rb
Example of using a simple future library for parallel HTTP requests
class TicketsController < ApplicationController
def show
tickets = params[:tickets].split(",")
ticket_data = tickets.map do |ticket|
parallel { Faraday.get("http://tickets.local/#{ticket}") }
end
render json: { tickets: ticket_data.map(&:result) }
end
class CorsSupport
def initialize(app)
@app = app
end
def call(env)
if preflight?(env)
env['HTTP_ORIGIN'] = 'file://' if env['HTTP_ORIGIN'] == 'null'
env['HTTP_ORIGIN'] ||= env['HTTP_X_ORIGIN']
@boy-jer
boy-jer / email.rb
Created May 24, 2012 14:12 — forked from ahawkins/email.rb
class Email
class Email < Message
attr_accessor :to, :cc, :bcc
validates :to, :presence => true, :on => :create
validates :to, :cc, :bcc, :emails => true
normalize_attribute :subject, :message
attr_accessible :to, :cc, :bcc, :subject, :message