Skip to content

Instantly share code, notes, and snippets.

View mbriggs's full-sized avatar

Matt Briggs mbriggs

View GitHub Profile
@mbriggs
mbriggs / gist:3252831
Created August 3, 2012 23:59
composition
class CodeMonkey
attr_reader :programming_language
def initialize(language)
@programming_language = language
end
def program!
programming_language.do_your_magic!
end
(require 'webjump)
; hax - I want webjump to default to word-at-point if there is a word-at-point
(defun webjump-read-string (prompt)
(let* ((prompt (concat prompt (if (word-at-point) (concat " (default: " (word-at-point) ")")) ": "))
(input (read-string prompt)))
(if (webjump-null-or-blank-string-p input) (word-at-point) input)))
(setq webjump-sites
(defun webjump-read-string (prompt)
(let* ((prompt (concat prompt (if (word-at-point) (concat " (default: " (word-at-point) ")")) ": "))
(input (read-string prompt)))
(if (webjump-null-or-blank-string-p input) (word-at-point) input)))
(setq mac-option-key-is-meta nil)
(setq mac-command-key-is-meta t)
(setq mac-command-modifier 'meta)
(setq mac-option-modifier nil)
=begin
We have a larger app, and we have (or are starting to have)
application services as facades to modules. When you have those,
a lot of the controller code becomes simple delegation. It would
be great to add a bit of sugar to make that delegation as painless
as regular controller methods.
Ideally, we would map from the router straight to our classes
(kind of like raptor style controllers). But since rails _really_
doesn't support that kind of thing, it would be nice if the controller
_.bindAll(this)
this.bindTo(this.collection, 'add', this.createdPct)
this.bindTo(this.collection, 'destroy', this.pctRemoved)
this.bindTo(this.collection, 'error', this.setErrors)

Making a reusable, extendable table widget with marionette that supports CRUD

I work on a mainly server-side, horribly complex, and quite large (247 kloc) rails app. Re-use of components and testability are probably our biggest concerns. I want to introduce the team to Backbone and Marionette, so this will take place during an extended lunch and learn. Probably won't TDD it due to the amount of content I want to cover

steps

first, need to make a basic editable table

  • Make a composite view (table/container), creator view (for "new" row), and item view (for "edit/show" of rows)
  • Item view overrides getTemplate to switch between edit/show modes
this.player.on("audio-ended", this.next, this)
@mbriggs
mbriggs / gist:3668572
Created September 7, 2012 18:53
Stack trace A
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/util/tcp_socket.rb:64:in `select'
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/util/tcp_socket.rb:64:in `read'
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/networking.rb:338:in `receive_data'
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/networking.rb:323:in `receive_message_on_socket'
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/networking.rb:188:in `receive_header'
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/networking.rb:175:in `receive'
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/networking.rb:139:in `receive_message'
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/cursor.rb:469:in `block in send_initial_query'
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/util/logging.rb:36:in `instrument'
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/cursor.rb:467:in `send_initial_query'
@mbriggs
mbriggs / gist:3668576
Created September 7, 2012 18:54
Stack Trace B - set_timezone_from_user
/usr/ruby1.9.2/lib/ruby/1.9.1/thread.rb:71:in `sleep'
/usr/ruby1.9.2/lib/ruby/1.9.1/thread.rb:71:in `wait'
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/util/pool.rb:298:in `block (2 levels) in checkout'
:
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/util/pool.rb:252:in `block in checkout'
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/util/pool.rb:245:in `loop'
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/util/pool.rb:245:in `checkout'
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/connection.rb:500:in `checkout_writer'
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/cursor.rb:524:in `checkout_socket_from_connection'
.bundle/gems/ruby/1.9.1/gems/mongo-1.6.2/lib/mongo/cursor.rb:466:in `send_initial_query'