Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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}"
# custom current_gemset check
function my_rbenv_current_gemset(){
rbenv gemset active &>/dev/null
if [ $? -eq 0 ]; then
local gemset="$(rbenv gemset active 2>/dev/null)"
echo "$gemset"
else # an error status means no gemsets
echo "NO_GEMSET"
fi
@bowsersenior
bowsersenior / every_combo.rb
Created July 25, 2012 00:59
Find every possible combination of a hash
class Hash
def every_combo
arr = self.to_a
1.upto(arr.size).inject([]) do |memo, n|
memo << arr.combination(n).to_a.map{|a| Hash[a] }
memo
end.flatten
end
end
@bowsersenior
bowsersenior / mountain-lion-brew-setup.markdown
Created July 27, 2012 18:39 — forked from yetanothernguyen/mountain-lion-brew-setup.markdown
Get Mountain Lion and Homebrew to Be Happy

Get Mountain Lion and Homebrew to Be Happy

1) Install XCode 4.4 into /Applications

Get it from http://developer.apple.com. You will not be able to submit apps to any stores using this XCode version, so turn away if that is something you might want to do.

2) Install Command Line Tools

In XCode's Preferences > Downloads you can install command line tools.

@bowsersenior
bowsersenior / README.md
Created August 18, 2012 17:04
Gauntlt with turnip

Proof of concept of using Turnip as the engine for gauntlt

How to use this code

TL;DR

$ git clone git://gist.github.com/3388412.git spec
$ gem install turnip aruba
$ rspec -r ./spec/spec_helper.rb -r ./spec/steps/gauntlt_steps.rb spec/nmap_turnip.attack --format documentation