Skip to content

Instantly share code, notes, and snippets.

@garybernhardt
garybernhardt / selectable_queue.rb
Last active November 23, 2022 12:42
A queue that you can pass to IO.select.
# A queue that you can pass to IO.select.
#
# NOT THREAD SAFE: Only one thread should write; only one thread should read.
#
# Purpose:
# Allow easy integration of data-producing threads into event loops. The
# queue will be readable from select's perspective as long as there are
# objects in the queue.
#
# Implementation:
@tjbladez
tjbladez / computed.coffee
Created May 8, 2012 17:16
basic computed properties in backbone
Namespace.models.Base = Backbone.Model.extend
initialize: ()->
Backbone.Model::initialize @, arguments
return if _.isUndefined(@computed)
@_computed = {}
for attr, dependencies of @computed
@on "change:#{attr}", ()=>
@chetan
chetan / yardoc_cheatsheet.md
Last active April 16, 2024 23:49
YARD cheatsheet
@alexaivars
alexaivars / setter_pattern.coffee
Created January 12, 2012 08:41
Getter Setter patter for Coffeescript
Function::define = (prop, desc) ->
Object.defineProperty this.prototype, prop, desc
class GetterSetterTest
constructor: (@_obj = {}) ->
# 'obj' is defined via the prototype, the definition proxied through
# to 'Object.defineProperty' via a function called 'define' providing
# some nice syntactic sugar. Remember, the value of '@' is
# GetterSetterTest itself when used in the body of it's class definition.