Skip to content

Instantly share code, notes, and snippets.

View sgharms's full-sized avatar

Steven G. Harms sgharms

View GitHub Profile
1 #!/usr/bin/ruby
2 require 'pp'
3
4 module Larry
5 def foo_cluster;
6 puts "in foo_cluster"
7 puts "<<#{__method__}>>"
8 end
9 def foo_cluster_alpha; puts "in foo_cluster_alpha" ; end
10 def foo_cluster_beta; puts "in foo_cluster_beta" ; end
@sgharms
sgharms / why can't I upgrade?
Created March 10, 2011 02:45
why can't I upgrade?
sgharms@stharms-mac:~/gitcheckouts/rdoc$ rake test
e(in /Users/sgharms/gitcheckouts/rdoc)
rake aborted!
undefined method `plugin' for Hoe:Class
/Users/sgharms/gitcheckouts/rdoc/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
sgharms@stharms-mac:~/gitcheckouts/rdoc$ gem install hoe-git
ERROR: Error installing hoe-git:
hoe requires RubyGems version >= 1.4. Try 'gem update --system' to update RubyGems itself.
sgharms@stharms-mac:~/gitcheckouts/rdoc$ gem update --system
@sgharms
sgharms / gist:1028581
Created June 16, 2011 02:56
Fun with metaprogramming in Ruby
#!/usr/bin/env ruby
module Magic
def self.active_voice_indicative_mood_present_tense(spec)
puts "hey you called me, with an argument of #{spec}"
end
end
class Zabu
def razzle
@sgharms
sgharms / gist:1148023
Created August 15, 2011 22:20
unclemantis
#!/usr/bin/env ruby
#
foo = []
0.upto 5 do |i|
- foo[i] = {}
end
foo[0]['jackpot'] = 100
foo[1]['jackpot'] = 200
foo[2]['jackpot'] = 500
foo[3]['jackpot'] = 300
Woman = (function() {
__extends(Woman, Primate);
function Woman(name) {
this.name = name != null ? name : 'Eve';
this.likes = [];
}
Woman.prototype.supply_likes = function() {
this.likes.push("someStuff");
return this.likes.push("someOtherStuff");
@sgharms
sgharms / gist:1601458
Created January 12, 2012 16:31
GET /tasks Rails log
#===============================================================================
## INITIAL PAGE VISIT ##
#===============================================================================
GET /tasks (no params)
Processing by TasksController#index as HTML
Employee Load (0.5ms) SELECT "employees".* FROM "employees" WHERE "employees"."id" = 1 LIMIT 1
Task Load (0.9ms) SELECT DISTINCT(completed_on) FROM "tasks" WHERE "tasks"."employee_id" = 1 AND (completed_on <= '2012-01-12') ORDER BY completed_on DESC LIMIT 5
class Employee < ActiveRecord::Base
...
def recent_tasks(options = {})
completed_on = if options[:completed_on].present?
Date.parse options[:completed_on]
else
Date.current
end
completed_on = 2.business_days.after(completed_on.to_time).to_date
<a id="previous" href="#"></a>
<% for task in @tasks: %>
<span class="date <%= task.status() %>" data-date="<%= task.get 'completed_on' %>">
<p class="time"><%= task.get 'time' %></p>
<p class="name"><%= Date.parse(task.get('completed_on')).toString 'ddd' %></p>
<p class="range">
<a href="#"><%= Date.parse(task.get('completed_on')).toString 'MM/dd' %></a>
</p>
</span>
<% end %>
class Timesheet.Views.DateScrollView extends Backbone.View
el: '.DateScrollPane'
template: JST['tasks/date_scroll_view']
initialize: ->
@collection.bind 'reset', @render
...
@model.bind 'change:completed_on', @refreshSelection
...
render: =>
completedOn = Date.parse @model.get('completed_on')
@sgharms
sgharms / gist:1603633
Created January 12, 2012 22:46
Add line numbers to your GitHub gists from within Markdown within a WordPress installation
<script type="text/javascript">
/*
* Add this to the top of your post. This will get interpreted in and applies to your page
* e.g.
*
* (this code)
*
* # My Summer Vacation
*