Skip to content

Instantly share code, notes, and snippets.

View cjbottaro's full-sized avatar

Christopher J. Bottaro cjbottaro

  • AcademicWorks, Inc
  • Austin, Tx
View GitHub Profile
@cjbottaro
cjbottaro / gist:10920007
Last active August 29, 2015 13:59
duplicate percolator results
require "elasticsearch"
client = Elasticsearch::Client.new
if !client.indices.exists(index: "percolator_test")
client.indices.create index: "percolator_test"
end
client.indices.put_mapping index: "percolator_test",
type: "type1",
@cjbottaro
cjbottaro / gist:9400140
Last active August 29, 2015 13:57
Promises and event handlers ?
doShow = ->
new RSVP.Promise (resolve, reject) ->
$("blah").off("shown.bs.modal")
$("blah").on "shown.bs.modal", (e) ->
resolve("I'm shown!")
$("blah").modal("show")
doShow().then (message) ->
console.log(message) # => "I'm shown!"
@cjbottaro
cjbottaro / gist:9163450
Last active November 18, 2016 19:18
Memoizing in Ruby 2 with prepend
module Memoizable
def self.extended(mod)
mod.module_eval{ prepend(@memoizer = Module.new) }
end
def memoize(name)
@memoizer.module_eval do
define_method(name) do |*args, &block|
raise(ArgumentError, "cannot memoize method called with block") if block
@cjbottaro
cjbottaro / gist:8378583
Created January 11, 2014 23:54
Climbing accident at Seismic on 2014-11-01
Climber was on Bird Dog, had the last bolt clipped and was trying to figure out how to clip the chains. He was experimenting with different beta and tried to go a little left, about 2-3 ft left of the bolt. He didn't like it, and started to down climb, lost his footing and fell. Since he was off to the left, he was pulled to the right when he fell, and rolled backwards off the right side of the ledge. He was pretty much upside side down when the rope caught and he slammed into the rock back first. Because it was a pendulum fall, he swayed back towards the left, and hit the back of his head on the rock below the ledge.
After examining his head, I decided he needed a few stitches, so we packed up our stuff and started to walk out. He complained of loss of vision, ringing ears and trouble standing, at which point he lay down and I called EMS.
He was taken to Brackenridge and released after 2 staples and a CAT scan. All is well, Dr's said he's fine and can continue climbing when the staples heal.
About
@cjbottaro
cjbottaro / gist:7162130
Created October 25, 2013 21:29
Like Python!
module Foo
extend(self)
def foo
"foo"
end
end
Foo.foo
# => "foo"

Roger Zelazny. For a Breath I Tarry

They called him Frost. Of all things created of Solcom, Frost was the finest, the mightiest, the most difficult to understand.

This is why he bore a name, and why he was given dominion over half the Earth.

On the day of Frost's creation, Solcom had suffered a discontinuity of complementary functions, best described as madness. This was brought on by an unprecedented solar flareup which lasted for a little over thirty-six hours. It occurred during a vital phase of circuit-structuring, and when it was finished so was Frost.

Solcom was then in the unique position of having created a unique being during a period of temporary amnesia.

@cjbottaro
cjbottaro / gist:2937550
Created June 15, 2012 16:53
content for navbar
# app/views/layouts/application.html.erb
<% if content_for?(:navbar) %>
<%= yield(:navbar) %>
<% else %>
<%# default navbar %>
<section class="navbar"></section>
<% end %>
# app/views/blah/show.html.erb
<% content_for(:navbar) %>
@cjbottaro
cjbottaro / gist:2926951
Created June 13, 2012 22:41
Adding methods to ActiveRecord::Relation to wrap results
require "spec_helper"
class RecordWrapper
def initialize(record)
@record = record
end
end
module RelationWrapping
<table class="normalize-size">
<<<<<<< HEAD
<tbody>
<tr>
<td><%= t("oa.users.system.display_name") %></td>
<td><%= user.display_name %></td>
</tr>
<tr>
@cjbottaro
cjbottaro / gist:1760846
Created February 7, 2012 17:29
bug with Queue
# ruby-1.9.3-p0
# Run in IRB...
require "thread"
q = Queue.new
q.pop # fatal: deadlock detected
q.pop # blocks properly