Skip to content

Instantly share code, notes, and snippets.

View davebrace's full-sized avatar
💭
🌔

Dave Brace davebrace

💭
🌔
View GitHub Profile

Keybase proof

I hereby claim:

  • I am davebrace on github.
  • I am davebrace (https://keybase.io/davebrace) on keybase.
  • I have a public key whose fingerprint is 5BE6 E5D9 1B4A D2E2 1E78 4ABB B6FA B6A0 5498 6E6E

To claim this, I am signing this object:

@davebrace
davebrace / gist:be25f2b343f1288b2895
Created April 29, 2015 22:02
Update a spreadsheet of company websites with if they use Google Apps
require "csv"
require "public_suffix"
require "active_support/all"
require "resolv"
def parse_domain(url)
return url unless url.present?
domain = url.strip.match(/\A(https?:\/\/(www\.)?)?([^\/]*)\/?/i)[3].downcase
parsed_domain = PublicSuffix.parse(domain).domain
rescue PublicSuffix::DomainInvalid
@davebrace
davebrace / install_neo4j_codeship.sh
Last active May 3, 2021 23:56
Install Neo4j (2.1.5) on Codeship running on specific ports
# Put the following lines in your Codeship Setup section
## Install Neo4j
wget -O neo4j-community-2.1.5.tar.gz http://neo4j.com/artifact.php?name=neo4j-community-2.1.5-unix.tar.gz
tar -xzvf neo4j-community-2.1.5.tar.gz
# configure neo4j to run on testing ports (7476 + 7475)
sed -i s/7474/7476/g neo4j-community-2.1.5/conf/neo4j-server.properties
sed -i s/7473/7475/g neo4j-community-2.1.5/conf/neo4j-server.properties
neo4j-community-2.1.5/bin/neo4j start
bundle exec rspec spec --tag data_store:neo4j
@davebrace
davebrace / Preferences.sublime-settings
Created February 18, 2014 18:32
Dave's Sublime Settings
{
"color_scheme": "Packages/Solarized Color Scheme/Solarized (light).tmTheme",
"ensure_newline_at_eof_on_save": true,
"folder_exclude_patterns":
[
"log",
"tmp",
".git"
],
"font_size": 22,
@davebrace
davebrace / p4merge-windows
Created March 17, 2013 20:31
p4merge settings for Git on Windows.
git config --global mergetool.p4merge.path 'C:\Program Files\Perforce\p4merge.exe'
git config --global merge.tool p4merge
@davebrace
davebrace / copy_heroku_db_between_apps.sh
Created January 31, 2013 16:02
Script to restore a Heroku postgres database from one Heroku Rails app to another, assuming only one postgres database in the app. I use this to copy production databases onto staging environments.
heroku pgbackups:capture --expire -a myapp
heroku pg:reset `heroku config -a myapp-staging | grep -o "\w*POSTGRESQL\w*"` -a myapp-staging
heroku pgbackups:restore `heroku config -a myapp-staging | grep -o "\w*POSTGRESQL\w*"` `heroku pgbackups:url --app myapp` --app myapp-staging
heroku run rake db:migrate -a myapp-staging
heroku restart -a myapp-staging
@davebrace
davebrace / page_scraper.rb
Last active December 10, 2015 05:58
Scrape a product web page to extract title / images / prices.
require 'open-uri'
require 'nokogiri'
doc = Nokogiri::HTML(open('http://www.amazon.com/Datacolor-Spyder4Pro-S4P100-Colorimeter-Calibration/dp/B006TF37H8'))
images = doc.xpath('//img/@src').map {|n| n.value }
title = doc.xpath('//title').text
prices = doc.to_s.scan(/\$(\d+(?:\.\d{1,2})?)/)