Skip to content

Instantly share code, notes, and snippets.

View westonplatter's full-sized avatar

westonplatter

View GitHub Profile
@westonplatter
westonplatter / echoHttpRequest.js
Last active August 29, 2015 14:21 — forked from Marak/echoHttpRequest.js
Echo HTTP requests
module['exports'] = function echoHttp (hook) {
hook.debug("Debug messages are sent to the debug console");
hook.debug(hook.params);
hook.debug(hook.req.path);
hook.debug(hook.req.method);
var wg sync.WaitGroup
numWorkers := 10
inputChannel := make(chan []string)
for i := 0; i < numWorkers; i++ {
wg.Add(1)
go func() {
for data := range inputChannel {
// do work
}
# example take from
# https://github.com/schneems/wicked/blob/40443aea2aba0fe506b9c878fb677f08f2114200/lib/wicked/wizard.rb
require 'active_support/concerns'
module FooBar::Concerns::Controllers::OneController
extend ActiveSupport::Concerns
# controller level methods associated with a Rails-route and View
# IE, the controller structure
@westonplatter
westonplatter / engines.md
Created July 24, 2012 09:11
Rails Docs - Engines - better formatting
# MyApp/app/models/blorgh/post.rb
# overrides Blorgh's original Post model

class Blorgh::Post < ActiveRecord::Base
  include Blorgh::Concerns::Models::Post

  def time_since_created
    Time.current - created_at
 end
lasdjflksdajfklj
@westonplatter
westonplatter / symbols.rb
Created August 10, 2012 22:42
namespace_ops
# want to see module/classes referenced via symbols.
# put this into IRB
module M # Main is 3 keys longer than M
class A
def test
"a"
end
end
> mongo
// saving records
db.test.save({"a": 1}) //
db.test.find() // { "_id" : ObjectId("502437b4a1d603739ab59206"), "a" : 1 }
db.test.save({"a": 100}) //
// retreaving range of records
db.test.find( { "a": { $gt: 0, $lt: 500 } } ) // { "_id" : ObjectId("502437b4a1d603739ab59206"), "a" : 1 }
// { "_id" : ObjectId("502675b7792a4a17c3b470b6"), "a" : 100 }
@westonplatter
westonplatter / methods.rb
Created August 22, 2012 00:19
open_classing
class Tweet
attr_accessor :status
attr_reader :created_at
def initialize(status)
@status = status
@created_at = Time.now
end
end
app1
|- app/views/photo_contests
| |- index.html.erb # => custom view template #1
|
\- Gemfile (gem 'common_engine')
app2
|- app/views/photo_contests
| |- index.html.erb # => custom view template #2
|