Skip to content

Instantly share code, notes, and snippets.

@elvuel
elvuel / 1-layout.html
Created February 21, 2012 04:09 — forked from mxriverlynn/1-layout.html
render backbone views with jquery templates
<html>
<head>
<script src="jquery-1.6.1.min.js"></script>
<script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script src="underscore-min.js"></script>
<script src="backbone-min.js"></script>
<script src="example.js"></script>
<style type="text/css">
fieldset {
@elvuel
elvuel / jasmine.yml
Created March 2, 2012 08:09 — forked from juno/jasmine.yml
jasmine initで生成されるjasmine.yml
# src_files
#
# Return an array of filepaths relative to src_dir to include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# src_files:
# - lib/source1.js
# - lib/source2.js
@elvuel
elvuel / eventmachine-fork-example.rb
Created March 6, 2012 13:22 — forked from kwilczynski/eventmachine-fork-example.rb
EventMachine with fork and children ...
require 'rubygems'
require 'eventmachine'
children = []
Signal.trap('SIGINT') do
EventMachine.next_tick { EventMachine.stop_event_loop }
end
Signal.trap('EXIT') do
@elvuel
elvuel / cranking.rb
Created March 6, 2012 13:23 — forked from raggi/cranking.rb
EventMachine.crank
require 'thread'
module EventMachine
module Test
module Utils
module Cranking
# Stolen from MenTaLguYs Omnibus
class Waiter
def initialize
class SomeMiddleware
def initialize(app) @app = app end
def call(env)
background(env) { ... }
@app.call env
end
def background(env, &block)
if env['rack.run_once'] then yield
require 'logger'
require 'openssl'
class UcellGateway
#dunno what this is, but it's yours :)
include MessageFilter
def initialize
@logger = Logger.new
@elvuel
elvuel / gist:1986329
Created March 6, 2012 13:40 — forked from Dremora/gist:709312
EventStream
require 'sinatra'
require 'eventmachine'
class EventStream
include EventMachine::Deferrable
def initialize(channel, &block)
@channel = channel
@block = block
@elvuel
elvuel / backbone.iframe.sync.js
Created March 8, 2012 05:25 — forked from unixcharles/backbone.iframe.sync.js
Backbone.sync implementation that use iframe + multipart/form-data
(function () {
Backbone.syncWithoutUpload = Backbone.sync
Backbone.syncWithUpload = function(method, model, options) {
// Create iframe
var iframe_id = 'file_upload_iframe_' + Date.now()
, iframe = jQuery('<iframe id="' + iframe_id + '" name="' + iframe_id + '" ></iframe>').hide()
// Create an hidden form
var authToken = jQuery('meta[name=csrf-token]').attr('content')
, authParam = jQuery('meta[name=csrf-param]').attr('content')
@elvuel
elvuel / paginated_collection.js
Created March 31, 2012 01:52 — forked from io41/paginated_collection.js
Pagination with Backbone.js
// includes bindings for fetching/fetched
var PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
typeof(options) != 'undefined' || (options = {});
this.page = 1;
typeof(this.perPage) != 'undefined' || (this.perPage = 10);
},
fetch: function(options) {
@elvuel
elvuel / git-cheat.rdoc
Created April 6, 2012 08:50 — forked from jschementi/git-cheat.rdoc
Git cheatsheets

Add colors to your ~/.gitconfig file:

[color]
  branch = auto
  diff = auto
  status = auto
[color "branch"]
  current = yellow reverse
  local = yellow
  remote = green
[color "diff"]