Skip to content

Instantly share code, notes, and snippets.

View seth-macpherson's full-sized avatar

Seth MacPherson seth-macpherson

  • Appfolio
  • Hood River, OR
View GitHub Profile
@seth-macpherson
seth-macpherson / app.rb
Created September 17, 2012 18:05
question
@analytics_status = EntityStore[:last_analytics_check]
if Time.now() > @analytics_status[:date] + 24.hours || @analytics_status[:status] == "FAIL"
rc = Alert.count
unless rc > W@analytics_status[:count]
@analytics_status[:status] = "FAIL"
else
@analytics_status[:status] = "OK"
@analytics_status[:count] = rc
end
@analytics_status[:date] = Time.now
@seth-macpherson
seth-macpherson / send_grid_example_controller.rb
Created October 2, 2012 18:40
SendGrid Event Webhooks Controller
class SendGridExampleController < ApplicationController
# code excerpt ...
def parse_event
unless params[:event].present?
result = {:msg => ABORTED, :success => false}
end
@seth-macpherson
seth-macpherson / Gemfile
Created November 26, 2012 22:24
Sample Gemfile with Selenium
group :test do
gem 'turn'
gem 'minitest'
gem 'factory_girl_rails', '4.0.0'
gem 'factory_girl', '4.0.0'
gem 'launchy'
gem 'simplecov', :require => false
gem 'capybara', '1.1.2'
gem 'selenium-client', '1.2.18'
@seth-macpherson
seth-macpherson / 0-readme.md
Created November 30, 2012 19:31 — forked from burke/0-readme.md
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@seth-macpherson
seth-macpherson / 0-readme.md
Created November 30, 2012 19:31 — forked from burke/0-readme.md
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@seth-macpherson
seth-macpherson / install.bash
Created December 10, 2012 22:17
Install RVM
curl -L https://get.rvm.io | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 185 100 185 0 0 513 0 --:--:-- --:--:-- --:--:-- 1201
100 10242 100 10242 0 0 4975 0 0:00:02 0:00:02 --:--:-- 17280
Downloading RVM from wayneeseguin branch master
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 131 100 131 0 0 183 0 --:--:-- --:--:-- --:--:-- 279
(rubybook) $ irb
1.9.3p125 :001 > require 'rubygems'
=> false
1.9.3p125 :002 > require 'selenium-webdriver'
=> true
1.9.3p125 :003 > driver = Selenium::WebDriver.for :firefox
Errno::EADDRNOTAVAIL: Cannot assign requested address - bind(2)
from /home/seth/.rvm/gems/ruby-1.9.3-p125/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/firefox/socket_lock.rb:45:in `initialize'
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00051s latency).
rDNS record for 127.0.0.1: assets.hiringthing-sm.com
Not shown: 997 closed ports
PORT STATE SERVICE
23/tcp open telnet
53/tcp open domain
631/tcp open ipp
Nmap done: 1 IP address (1 host up) scanned in 0.10 seconds
require 'socket'
Socket.do_not_reverse_lookup = true
UDPSocket.open do |s|
s.connect '8.8.8.8', 1
p s.addr.last
end
require 'socket'
Socket.do_not_reverse_lookup = true
UDPSocket.open do |s|
s.connect '8.8.8.8', 1
p s.addr.last
end
# 85.17.96.111, 65.21.182.202