Skip to content

Instantly share code, notes, and snippets.

var sys = require('sys'),
http = require('http'),
events = require('events'),
router = require('./lib/router').createRouter();
// Routing table
router.get('/handlers/:name/messages', function(name) {
var response = this.response;
response.writeHead(200, {'Content-Type': 'text/plain'});
handlers[name].addListener('message', function(message) {
success_count = 0
fail_count = 0
lock = Mutex.new
DB = Application.db
DB.drop_table :race_test rescue nil
DB.create_table :race_test do
@jstotz
jstotz / settings.snippet.coffee
Created May 3, 2011 21:29 — forked from igustafson/settings.snippet.coffee
Settings TableView with delete link
rowView =
events:
'click .destroy': 'destroy'
destroy: (event)->
event.preventDefault()
if confirm("Are you sure you want to delete " + setting.get("id") + "?")
@model.destroy()
class TableView extends Sagamore.Views.CollectionTable
@jstotz
jstotz / output.png
Created June 27, 2011 16:50
Codebrawl #2
output.png
if row[:item_properties]
item_properties = JSON.parse(row[:item_properties])
item_property_array = item_property_columns.map {|c| item_properties[c]}
else
item_property_array = item_property_columns.size.times.map { nil }
end
@jstotz
jstotz / gist:1820315
Created February 13, 2012 20:53
Ruby Enumerable#zip
enum1 = [:a, :b, :c]
enum2 = [1, 2, 3]
enum1.zip(enum2) do |x, y|
puts "#{x} -> #{y}"
end
# Output:
# a -> 1
# b -> 2
# c -> 3
@jstotz
jstotz / gist:4033022
Created November 7, 2012 17:14
Terminal prompt after reading $stdin
puts "Reading lines..."
$stdin.each_line do |line|
puts "IN: #{line}"
end
$stdin.reopen File.open("/dev/tty", "r")
puts "Awaiting user input..."
# ...
fetchAll: ->
@fetchTickets().
pipe(=> @fetchTicketLines()).
pipe(=> @fetchInventory()).
pipe(=> @fetchBinLocations())
# ...
# ...

Keybase proof

I hereby claim:

  • I am jstotz on github.
  • I am jstotz (https://keybase.io/jstotz) on keybase.
  • I have a public key ASCVpXFXPpsgEho01EXUTOUbfPGKlZDxEizLjhaTqMCaDwo

To claim this, I am signing this object:

Sequel.migration do
no_transaction
change do
alter_table :foo do
add_column :bar, String
add_index :bar, concurrently: true
end
end
end