Skip to content

Instantly share code, notes, and snippets.

View kbrock's full-sized avatar

Keenan Brock kbrock

View GitHub Profile
--applescript
tell application "Safari"
activate
set google_tab to current tab of first window
-- google currently open in the screen
tell google_tab
do JavaScript "document.f.q.value='mac ruby'"
end tell
end tell
framework 'ScriptingBridge'
safari = SBApplication.applicationWithBundleIdentifier('com.apple.Safari')
google_tab=safari.windows.first.currentTab
cmd="document.f.q.value='mac ruby'"
safari.performSelector(:"doJavaScript:in:", withObject:cmd, withObject:google_tab)
@kbrock
kbrock / example.rb
Created June 5, 2009 13:25
copy an irb command to clipboard
copy {
puts "puts 'hello world'"
}
#command V
ep
# Apple Script to open google in a new tab
# tell application "Safari"
# make new document
# set URL of first document to "http://www.google.com"
# end tell
# rb-appscript to do the same
# app("Safari").make(:new => :document)
# app("Safari").documents[1].URL.set("http://www.google.com")
module ActiveRecord
##idea is from lovdbyless
##These extensions give database specific implementations for common functions
module ConnectionAdaptersExt
module MySQL
def rand
'RANDOM()'
end
def now
'NOW()'
@kbrock
kbrock / 01_before.txt
Created October 1, 2010 12:23
Hirb example
>> Disease.find(2)
=> #<Disease id: 2, name: "MS", symptom_survey_lifespan: 30, disease_status_id: 3, key: "ms", community_manager_id: 3187, created_at: nil, updated_at: nil>
>> User.first
# => #<User id: 22, verified: true, deleted: false, created_at: "2008-07-03 13:36:57", updated_at: "2010-09-23 03:18:13", first_name: "Justin", last_name: "Smith", title: "wife", disease_id: 2, address: nil, city: "Boston", state: "MA", country: "United States", sex: nil, birth_date: nil, deceased_date: nil, permit_registry: nil, height: nil, display_height_unit: nil, display_weight_unit: nil, allows_public_view: false, lat: #<BigDecimal:1098c57d0,'0.28228671E2',18(18)>, lng: #<BigDecimal:1098c56e0,'-0.81653075E2',18(18)>, postcode: "02142", last_activity_time: "2008-07-03 13:38:10", last_update_time: nil, allows_badge: false, timezone: nil, phone: nil, messaging_privileges: nil, role_id: 5, unsubscribe_token: "21a497dae68b11780871083eddd6a3f201389bd6", welcome_message_sent_on: "2009-03-24", system_welcome_message_sent_o
@kbrock
kbrock / Gemfile
Created April 8, 2011 03:36
initializer to load debugger
gem 'rdebug', '0.1', :group => :development, :require => false
From bef595dbdbde5725b8d49242b10a400db38134d1 Mon Sep 17 00:00:00 2001
From: Ben Zack <bzack@patientslikeme.com>
Date: Mon, 11 Jul 2011 15:42:24 -0400
Subject: [PATCH] Added levenshtein distance for determining database name
from branch name
---
Gemfile | 1 +
Gemfile.lock | 2 ++
lib/devdb.rb | 18 ++++++++++++++++++
@kbrock
kbrock / bashrc.bash
Created March 7, 2012 13:21
Colored Git prompts
# thanks from: http://aaroncrane.co.uk/2009/03/git_branch_prompt/
function find_git_branch {
local dir=. head
git_dir=${PWD}
until [ "$dir" -ef / ]; do
if [ -f "$dir/.git/HEAD" ]; then
head=$(< "$dir/.git/HEAD")
if [[ $head == ref:\ refs/heads/* ]]; then
git_branch="${head#*/*/}"
elif [[ $head != '' ]]; then
@kbrock
kbrock / install.sh
Created September 25, 2012 21:34
nginx info
brew install nginx