Skip to content

Instantly share code, notes, and snippets.

View robrasmussen's full-sized avatar

Robert Rasmussen robrasmussen

View GitHub Profile
#!/usr/bin/env ruby
# The script that give you focus!
# Create a text file that contains sites want to give yourself
# access to only during certain times of day.
#
# The file will look like this:
# 12 news.ycombinator.com
# 11-13,19-21 twitter.com
#
#!/usr/bin/env ruby
# sanity.rb, the ruby script that keeps your twitter timeline manageable.
#
# This script is meant to be run every few hours, and will show you
# tweets from the people you tell it to. That guy that retweets every 10 minutes? You can
# leave him off your list.
#
# Create a file in yaml format that looks like this:
# auth:
javascript:document.querySelector("meta[name='viewport']").setAttribute("content", "width=device-width; initial-scale=1.0; maximum-scale=5.0; user-scalable=1;");
@robrasmussen
robrasmussen / active_record_playground.rb
Created October 3, 2010 07:50
I've been using variations of this for years to help figure out little problems with ActiveRecord.
require 'rubygems'
require 'active_record'
require 'logger'
ActiveRecord::Base.establish_connection({:adapter => "sqlite3", :database => ":memory:"})
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :people do |t|
@robrasmussen
robrasmussen / analytics.rb
Created March 3, 2011 17:53
Google Analytics with garb
#!/usr/bin/env ruby
#
require 'rubygems'
require 'garb'
require 'active_support/core_ext'
Garb::Session.login(ENV["GA_USERNAME"], ENV["GA_PASSWORD"])
profile = Garb::Management::Profile.all.find {|p| p.web_property_id == ENV["GA_UA_STRING"] }
#! /usr/bin/env ruby
class AdditionProblemGenerator
attr_accessor :max, :number_of_problems
def initialize(max = 20, number_of_problems = 20)
self.max = max
self.number_of_problems = number_of_problems
end
@robrasmussen
robrasmussen / gist:1557575
Created January 3, 2012 23:34
thread dump
[root@rhel6vm-community1 deployments]# /usr/java/jdk1.7.0_01/bin/jstack 7370
2012-01-03 17:30:59
Full thread dump Java HotSpot(TM) 64-Bit Server VM (21.1-b02 mixed mode):
"Attach Listener" daemon prio=10 tid=0x00007fd7dc001000 nid=0x221a waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"RubyThread-1: /usr/local/rvm/gems/jruby-1.6.5.1@torquebox_12_11/gems/torquebox-rake-support-2.0.0.beta1/lib/torquebox/deploy_utils.rb:293" daemon prio=10 tid=0x00007fd818686000 nid=0x1ce2 runnable [0x00007fd7e119f000]
java.lang.Thread.State: RUNNABLE
at java.io.FileInputStream.readBytes(Native Method)
TorqueBox.configure do
web do
context "/"
end
ruby do
version "1.9"
end
end
12:54:07,541 INFO [org.torquebox.core.runtime] (Thread-2 (HornetQ-client-global-threads-774148213)) Creating ruby runtime (ruby_version: RUBY1_9, compile_mode: JIT, app: frontend_02_13_2012_jruby, context: messaging)
12:54:20,115 INFO [org.torquebox.core.runtime] (Thread-2 (HornetQ-client-global-threads-774148213)) Created ruby runtime (ruby_version: RUBY1_9, compile_mode: JIT, app: frontend_02_13_2012_jruby, context: messaging) in 12.57s
12:54:20,550 ERROR [stderr] (Thread-2 (HornetQ-client-global-threads-774148213)) FutureResponder#respond: An error occured:
12:54:20,550 ERROR [stderr] (Thread-2 (HornetQ-client-global-threads-774148213)) uninitialized constant ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::PGconn
12:54:20,550 ERROR [stderr] (Thread-2 (HornetQ-client-global-threads-774148213)) /usr/local/jruby/lib/ruby/gems/1.8/gems/activesupport-2.3.11/lib/active_support/dependencies.rb:131:in `const_missing'
12:54:20,551 ERROR [stderr] (Thread-2 (HornetQ-client-global-threads-774148213)) /usr/local/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.11/lib/active_record/connection_adapters/postgresql_adapter.rb:941:in `connect'
12:54:20,551 ERROR [stderr] (Thread-2 (HornetQ-client-global-threads-774148213)) /usr/loca