Skip to content

Instantly share code, notes, and snippets.

View colmarius's full-sized avatar
💭
🎶 🎹

Marius Colacioiu colmarius

💭
🎶 🎹
View GitHub Profile
require "thread"
module Synchronizable
def self.included(base)
base.send(:include, InstanceMethods)
base.send(:extend, ClassMethods)
end
module ClassMethods
def synchronized(meth)
require "thread"
module Synchronization
class Proxy
instance_methods.each { |m| undef_method m unless m =~ /^__|extend/ }
def initialize(target)
@__target__ = target
end
module Decorating
def decorate(meth_id, *modules)
alias_method("__#{meth_id}__", meth_id)
define_method(meth_id) do |*args|
result = send("__#{meth_id}__", *args)
modules.each { |m| result.extend(m) }
return result
end
end
var performance = (function () {
var my = {};
// Wrap a function body in this to return a copy that instruments itself
// If you want this to be useful, you should give your profiled function a name,
// otherwise it will be identified as "", which is less than useful.
my.profile = function (func) {
return function () {
var start = new Date().getTime(),
time,

(a gist based on the old toolmantim article on setting up remote repos)

To collaborate in a distributed development process you’ll need to push code to remotely accessible repositories.

This is somewhat of a follow-up to the previous article setting up a new rails app with git.

For the impatient

Set up the new bare repo on the server:

@mkuklis
mkuklis / backbone_playground.js
Created November 15, 2010 08:05
playing with backbone
$(function() {
// data comes from server
var data = {title: "header title", body: "body title", background_color: "#ffffff"};
// setup site model and extend it with data from server
var Site = Backbone.Model.extend(data);
// header view
var HeaderView = Backbone.View.extend({
@jacob414
jacob414 / backbone-tutorial.js
Created November 18, 2010 12:54
Minimal example of data handling in Backbone.js
/* Scaled-down Backbone.js demonstration
* By Jacob Oscarson (http://twitter.com/jacob414), 2010
* MIT Licenced, see http://www.opensource.org/licenses/mit-license.php */
$(function() {
window.ulog = function(msg) { $('#log').append($('<div>'+msg+'</div>')); }
// Faking a little bit of Backbone.sync functionallity
Backbone.sync = function(method, model, succeeded) {
ulog('<strong>'+method + ":</strong> " + model.get('label'));
if(typeof model.cid != 'undefined') {
@zerowidth
zerowidth / paginated_collection.js
Created November 18, 2010 22:04
first whack at pagination with backbone.js
// includes bindings for fetching/fetched
PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
this.page = 1;
},
fetch: function(options) {
options || (options = {});
this.trigger("fetching");
@johnreilly
johnreilly / SubViews.html
Created December 2, 2010 18:19
My attempt at using Backbone.js views to render other "sub-views"
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/underscore.js" type="text/javascript"></script>
<script src="js/backbone.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
$(function(){
@cowboy
cowboy / pubsub-demo.js
Created December 16, 2010 20:04 — forked from rmurphey/pubsub-demo.js
Two approaches: "Traditional" vs Pub/Sub (via rmurphey)
// Note that this uses my Pub/Sub implementation, which is slightly different than
// phiggins' in that jQuery custom events are used, and as such the first event handler
// argument passed is the event object.
//
// jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery
// https://gist.github.com/661855
// The "traditional" way.