Skip to content

Instantly share code, notes, and snippets.

View RobinDaugherty's full-sized avatar

Robin Daugherty RobinDaugherty

View GitHub Profile
@RobinDaugherty
RobinDaugherty / rails console.rb
Created July 21, 2014 14:34
Troubleshoot chromedriver with jruby
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome, :service_log_path => 'chromedriver.out')
end
Capybara.default_driver = :chrome
include Capybara::DSL
visit "https://google.com"
@RobinDaugherty
RobinDaugherty / aperture-worker.conf
Created May 16, 2014 18:58
Upstart config for sidekiq workers
# /etc/init/sidekiq.conf - Sidekiq config
# This example config should work with Ubuntu 12.04+. It
# allows you to manage multiple Sidekiq instances with
# Upstart, Ubuntu's native service management tool.
#
# See aperture-workers.conf for how to manage all Sidekiq instances at once.
#
# Save this config as /etc/init/sidekiq.conf then mange sidekiq with:
# sudo start sidekiq index=0
def normalized_content_from_content
if client
options = {
blacklisted_elements: client.article_blacklisted_elements,
whitelisted_tags: client.article_whitelisted_tags,
}
else
options = nil
end
ContentNormalization.new(content, options).normalized_content if content
require 'rubygems'
require 'nokogiri'
require 'gollum'
wiki = Gollum::Wiki.new('auxwiki')
name = 'Ilja Krijger'
email = '[email protected]'
f = File.open("AuxiliumWiki-20110705103347.xml")
# Update, upgrade and install development tools:
apt-get update
apt-get -y install build-essential git-core aptitude
aptitude -y remove rbenv
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Set permissions
chgrp users -R /usr/local/rbenv
@RobinDaugherty
RobinDaugherty / 1_get-into-screen.sh
Last active January 4, 2016 18:39
Rails app on server
# To connect to the existing screen:
sudo screen -R -x
# - OR -
# If there wasn't already a screen running:
sudo screen -R
# This is a new screen, and you had to use root to start screen,
# so now change to the deploy user, setting up the correct environment.
@RobinDaugherty
RobinDaugherty / tm2-bundles.sh
Last active December 27, 2015 14:49 — forked from tonycoco/tm2-bundles
Textmate 2 bundles for Ruby on Rails development.
mkdir -p ~/'Library/Application Support/Avian/Bundles'
cd ~/'Library/Application Support/Avian/Bundles' && git clone https://github.com/cucumber/cucumber-tmbundle Cucumber.tmbundle
@RobinDaugherty
RobinDaugherty / README.md
Last active December 20, 2015 15:09
Load mysqldump into postgres using as many threads as possible.

psql is CPU-bound reading mysqldump output, so it's extremely slow to load records. This script runs as many instances of psql in parallel as possible.

Determines the number of CPUs, which has been tested in Ubuntu.

Assumes data loaded from mysql has timestamps in EST5EDT time zone and has been dumped using the following command line:

mysqldump -f --skip-tz-utc --skip-add-locks --skip-lock-tables --no-create-db --no-create-info --complete-insert --default-character-set=utf8 --max_allowed_packet=1M --net_buffer_length=1M --compatible=postgresql $database $table --result-file=$file;

@RobinDaugherty
RobinDaugherty / convert-to-utf8.rb
Created August 2, 2013 04:12
Uses https://github.com/brianmario/charlock_holmes to detect encoding of each line of input, converting to UTF-8 for output.
#!env ruby
#
# Converts character encoding of STDIN on a line-by-line basis.
# Properly-encoded UTF-8 is sent to STDOUT.
# Informative messages are sent to STDERR.
#
require 'charlock_holmes'
desired_encoding = 'UTF-8'
@RobinDaugherty
RobinDaugherty / convert-to-utf8.rb
Created August 2, 2013 04:12
Uses https://github.com/brianmario/charlock_holmes to detect encoding of each line of input, converting to UTF-8 for output.
#!env ruby
#
# Converts character encoding of STDIN on a line-by-line basis.
# Properly-encoded UTF-8 is sent to STDOUT.
# Informative messages are sent to STDERR.
#
require 'charlock_holmes'
desired_encoding = 'UTF-8'