Skip to content

Instantly share code, notes, and snippets.

@ryanbriones
ryanbriones / gist:246599
Created December 1, 2009 20:17
send email to gmail (STARTTLS) using ruby >=1.8.7
# send email using STARTTLS; Net::SMTP#enable_starttls requires ruby >=1.8.7
# this hack is needed for rails <2.3; apparently >=2.3 has something for this already
ActionMailer::Base.class_eval do
private
def perform_delivery_smtp(mail)
destinations = mail.destinations
mail.ready_to_send
smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])
@ryanbriones
ryanbriones / server.rb
Created April 22, 2011 01:12
basic event machine pubsub for ChicagoRuby
#!/usr/bin/env ruby
require "rubygems"
require "eventmachine"
class PubSubServer < EM::Connection
attr_accessor :channels
SubscriberChannel = EM::Channel.new
describe SomeController do
before(:each) do
# exisiting mock setup
end
# add to mocks, placement after before is key
it_should_behave_like "a before filter thingie"
it "blah"
end
@ryanbriones
ryanbriones / gist:6144388
Created August 3, 2013 00:00
JSON musical notation
{
"key_signature": {
"name": "C major",
"sharps": [],
"flats": [],
},
"time_signature": {
"upper": 4,
"lower": 4
},
@ryanbriones
ryanbriones / gist:5691547
Created June 1, 2013 19:57
Civic Needs Issue test
require "sinatra"
require "octokit"
class CivicNeedsIssuesList < Sinatra::Base
get "/" do
out = ""
Octokit.list_issues("ryanbriones/civicneeds", {:labels => "need"}).each do |issue|
out << %Q{<a href="/needs/#{issue.number}">##{issue.number} #{issue.title} (#{issue.comments} comments)</a>}
end
@ryanbriones
ryanbriones / intro_r_tutorial.md
Created August 10, 2012 02:22 — forked from jpvelez/intro_r_tutorial.md
Intro to R Tutorial

WHAT IS THIS?

This is a step-by-step tutorial for getting started with R, a powerful programming language for data analysis and visualization. It is aimed at near complete beginners. You'll basically want to be comfortable with spreadsheets and with using your computer's command line.

I slapped this together quickly, so expect some weirdness. Feel free to email me with comments or questions at jpvelez | at | gmail.com

I learned the following stuff using the UCLA Statistic's Department great R tutorials, so check those out:

@ryanbriones
ryanbriones / gist:3292129
Created August 8, 2012 04:44
Chicago Open Data Hack Night R Demo in Incanter
;; a naive implementation of the R intro demo from Chicago Open Data Hack Night
;; using clojure and incanter
;;
;; Data and explanation here: http://gathers.us/events/open-gov-hack-night-organized-by-open-city-ebf93
;;
;; * Download incanter-latest (1.2 right now)
;; * run `script/repl`
;; * copy in code
(use '(incanter core io stats charts))
@ryanbriones
ryanbriones / gist:3243872
Created August 3, 2012 02:54
Plain HTML "templates", with ERB layout, from Sinatra
class MySinatraApplication < Sinatra::Base
get "/some-mockup-path" do
html :somemockup
end
helpers do
def html(template, options = {}, locals = {})
render :html, template, options, locals
end
tell application "iTunes"
set the current EQ preset to EQ preset "Manual"
tell EQ preset "Manual"
set band 1 to -8
set band 2 to -5
set band 3 to -2
set band 4 to -4
set band 5 to -5
set band 6 to -6
set band 7 to -4
dumont:~ ryanbriones$ gem install morning-pages
Fetching: trollop-1.16.2.gem (100%)
Fetching: morning-pages-0.2.1.gem (100%)
Successfully installed trollop-1.16.2
Successfully installed morning-pages-0.2.1
2 gems installed
dumont:~ ryanbriones$ morning-pages help
sh: /Users/ryanbriones/words/2012-07-18: No such file or directory
/Users/ryanbriones/.rvm/gems/ruby-1.9.2-p180/gems/morning-pages-0.2.1/lib/morning-pages.rb:15:in `read': No such file or directory - /Users/ryanbriones/words/2012-07-18 (Errno::ENOENT)
from /Users/ryanbriones/.rvm/gems/ruby-1.9.2-p180/gems/morning-pages-0.2.1/lib/morning-pages.rb:15:in `stats_for_today'