Skip to content

Instantly share code, notes, and snippets.

View gnepud's full-sized avatar

Peng Du gnepud

  • Grenoble, France
View GitHub Profile
@gnepud
gnepud / coffee.js
Created July 5, 2012 20:25 — forked from grignaak/coffee.js
A requireJS plugin to load CoffeeScript
(function() {
var origDefine = define;
function redefine(name, definitions) {
return function (prereqs, definition) {
if (arguments.length > 2) {
throw new Error('Cannot have more than two arguments to define in ' + name);
} else if (arguments.length === 1) {
definition = prereqs;
prereqs = [];
@gnepud
gnepud / gist:3038589
Last active October 6, 2015 18:58
Backbone.js use mustashe syntax
_.templateSettings = {
evaluate: /\{\{#([\s\S]+?)\}\}/g, // {{# console.log("blah") }}
interpolate: /\{\{[^#\{]([\s\S]+?)[^\}]\}\}/g, // {{ title }}
escape: /\{\{\{([\s\S]+?)\}\}\}/g, // {{{ title }}}
};
@gnepud
gnepud / jquery.ba-tinypubsub.js
Created July 3, 2012 08:44 — forked from cowboy/HEY-YOU.md
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
@gnepud
gnepud / app.js
Created July 2, 2012 08:00 — forked from atinux/app.js
Backbone JS infinite data with Node JS and Express JS
/*
** Client side - /public/src/app.js
*/
var myApp = {
// Collections
Collections: {
list: Backbone.Collection.extend()
},
// Views
@gnepud
gnepud / active_model_serializers.rb
Created June 27, 2012 07:58 — 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)
@gnepud
gnepud / engine.rb
Created June 20, 2012 08:12
Testing routes with Rails 3.2 mountable engines and RSpec 2
# your-engine/lib/magic/rails/engine.rb
module Magic
module Rails
module Engine
##
# Automatically append all of the current engine's routes to the main
# application's route set. This needs to be done for ALL functional tests that
# use engine routes, since the mounted routes don't work during tests.
#
@gnepud
gnepud / rack_example.ru
Created June 17, 2012 18:12 — forked from rkh/rack_example.ru
Very basic rack application showing how to use a router based on the uri and how to process requests based on the HTTP method used.
#########################################
# Very basic rack application showing how to use a router based on the uri
# and how to process requests based on the HTTP method used.
#
# Usage:
# $ rackup rack_example.ru
#
# $ curl -X POST -d 'title=retire&body=I should retire in a nice island' localhost:9292/ideas
# $ curl -X POST -d 'title=ask Satish for a gift&body=Find a way to get Satish to send me a gift' localhost:9292/ideas
# $ curl localhost:9292/ideas
@gnepud
gnepud / rack_example.ru
Created June 17, 2012 18:07 — forked from mattetti/rack_example.ru
Very basic rack application showing how to use a router based on the uri and how to process requests based on the HTTP method used.
#########################################
# Very basic rack application showing how to use a router based on the uri
# and how to process requests based on the HTTP method used.
#
# Usage:
# $ rackup rack_example.ru
#
# $ curl -X POST -d 'title=retire&body=I should retire in a nice island' localhost:9292/ideas
# $ curl -X POST -d 'title=ask Satish for a gift&body=Find a way to get Satish to send me a gift' localhost:9292/ideas
# $ curl localhost:9292/ideas
@gnepud
gnepud / .pryrc
Created June 12, 2012 23:29 — forked from ches/.pryrc
Enable Hirb in Pry, and hack disable/enable to work in-session
if defined? Rails
begin
require 'hirb'
rescue LoadError
# Missing goodies, bummer
end
if defined? Hirb
# Dirty hack to support in-session Hirb.disable/enable
Hirb::View.instance_eval do
@gnepud
gnepud / ember_handlebars.rb
Created June 8, 2012 08:09 — forked from dagda1/ember_handlebars.rb
ember_handlebars.rb
require 'tilt'
require 'json'
class EmberHandlebars < Tilt::Template
def self.default_mime_type
"application/javascript"
end
def prepare
end