Skip to content

Instantly share code, notes, and snippets.

@bowsersenior
bowsersenior / gist:2997869
Created June 26, 2012 18:44 — forked from Victa/gist:1485536
My Textmate 2 .tm_properties
# Basic Settings
#
fontName = "Monaco"
fontSize = 12
# Extra files to include
#
myExtraIncludes = ".tm_properties,.htaccess,.gitignore"
fileBrowserGlob = "{*,$myExtraIncludes}"
include = "{$include,$myExtraIncludes}"
@bowsersenior
bowsersenior / os_x_dev_bootstrap.md
Last active October 6, 2015 12:58
OS X Lion from scratch

Mani's OS X (Mountain) Lion dev machine bootstrap guide:

Preliminary

  • Software Update

Utilities

  • Alfred (app store)
  • 1Password (app store)
@bowsersenior
bowsersenior / showoff-scraper.rb
Created May 24, 2012 00:15 — forked from ngty/showoff-scraper.rb
Showoff's (https://github.com/schacon/showoff) builtin pdf conversion doesn't work well for me, so i hacked up my own version ... & it works !!
#!/usr/bin/env ruby
require 'rubygems'
require 'RMagick'
require 'capybara'
require 'capybara/dsl'
# ================================================================
# Collect input args
# ================================================================
begin
@bowsersenior
bowsersenior / largest_prime_factor.rb
Created April 14, 2012 10:16
Fun with largest prime factors
BIG_NUMBER = 600_851_475_143
require 'prime'
def slow_largest_prime_factor_of(n)
possible_prime_factors = primes_up_to(Math.sqrt(n).to_i)
returner = nil
possible_prime_factors.each do |f|
if n % f == 0
returner = f
@bowsersenior
bowsersenior / jQueryEvents.rb
Created January 21, 2012 11:01 — forked from agirorn/jQueryEvents.rb
Trigger javascript event in Capybara
module JQueryEventsHelpers
def trigger_js_event(selector, event)
script = "$('#{selector}').trigger('#{event}')"
page.execute_script(script);
end
end
World(JQueryEventsHelpers)
@bowsersenior
bowsersenior / sleep_sort.rb
Created June 16, 2011 00:33
Sleep sort in ruby
#!/usr/bin/env ruby
# Outputs sorted args to stdout
# from:
# http://dis.4chan.org/read/prog/1295544154/170
def sleep_sort(*args)
args.each { |e| fork { sleep(e.to_f/1000); puts e } }
end
sleep_sort(*ARGV)
@bowsersenior
bowsersenior / stooge_loader.rb
Created May 18, 2011 23:18
A demo of YAML anchors, references and nested values
require 'rubygems'
require 'yaml'
# A demonstration of YAML anchors, references and handling of nested values
# For more info, see:
# http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/
stooges = YAML::load( File.read('stooges.yml') )
# => {
# "default" => {
@bowsersenior
bowsersenior / word_frequency_in_swifts_modest_proposal.sh
Created April 27, 2011 00:28
Calculates word frequencies from the text of Jonathan Swift’s, A Modest Proposal from http://tomayko.com/writings/awkward-ruby
# with AWK
curl -s http://www.gutenberg.org/files/1080/1080.txt |
awk '
BEGIN { FS="[^a-zA-Z]+" }
{
for (i=1; i<=NF; i++) {
word = tolower($i)
words[word]++
}
@bowsersenior
bowsersenior / closures-in-ruby.rb
Created March 23, 2011 23:33
A copy of Paul Cantrell's excellent info on ruby closures : http://innig.net/software/ruby/closures-in-ruby.rb
# CLOSURES IN RUBY Paul Cantrell http://innig.net
# Email: username "cantrell", domain name "pobox.com"
# I recommend executing this file, then reading it alongside its output.
#
# Alteratively, you can give yourself a sort of Ruby test by deleting all the comments,
# then trying to guess the output of the code!
# A closure is a block of code which meets three criteria:
require 'acceptance/acceptance_helper'
feature "Articles", %q{
In order to have an awesome blog
As an author
I want to create and manage articles
} do
background do
Article.create!(:title => 'One')