Skip to content

Instantly share code, notes, and snippets.

View RobinDaugherty's full-sized avatar

Robin Daugherty RobinDaugherty

View GitHub Profile
@RobinDaugherty
RobinDaugherty / .circleci-start-cassandra.sh
Created April 27, 2015 16:48
Cassandra timeout on CircleCI
#!/bin/bash
echo "describe cluster;" > /tmp/dc
for i in {1..5}; do
echo Attempt $i
if cassandra-cli -f /tmp/dc 2>&1 | grep "Cluster Information"; then
exit 0
else
sudo service cassandra stop; sudo service cassandra start
sleep 10
fi
@RobinDaugherty
RobinDaugherty / zendframework.rb
Created January 3, 2012 19:37
Install ZendFramework Homebrew Formula
require 'formula'
class Zendframework < Formula
url 'http://framework.zend.com/releases/ZendFramework-1.10.3/ZendFramework-1.10.3.tar.gz'
homepage 'http://framework.zend.com'
md5 'da0b497b2446f5612895d689821624e2'
version '1.10.3'
def install
prefix.install Dir['*']
@RobinDaugherty
RobinDaugherty / libsphinxclient.rb
Created December 6, 2012 20:13
Homebrew formula for libsphinxclient
require 'formula'
class Libsphinxclient < Formula
url 'http://sphinxsearch.com/files/sphinx-2.0.6-release.tar.gz'
homepage 'http://www.sphinxsearch.com'
sha1 'fe1b990052f961a100adba197abe806a3c1b70dc'
head 'http://sphinxsearch.googlecode.com/svn/trunk/'
def install
Dir.chdir "api/libsphinxclient" do
@RobinDaugherty
RobinDaugherty / founding_eu_partner.html
Created November 3, 2015 20:53
Ahalogy Partner Badges
<a href="https://www.ahalogy.com/publishers/"><img src="//badge.ahalogy.com/img/founding_eu_partner.png" title="Ahalogy Founding EU Partner" alt="Ahalogy Founding EU Partner"></a>
# Opens each model file alongside its corresponding spec file, even if the spec file doesn't yet exist.
# Waits for you to close the files before loading the next pair.
for i in app/models/**.rb; do
mate -w $i ${${i/app/spec}/.rb/_spec.rb}
done
class Picture < ActiveRecord::Base
attr_accessible :picture, :picture_105px_width, :picture_120px_width
has_many :pin
end
@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'
@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 / app.controllers.projectname_page_controller.rb
Created December 22, 2015 18:54
ember_cli_deploy_redis_ruby v1.0.0 Rails controller implementation
class ProjectNamePageController < BaseEmberCliDeployController
def index
render_page('index.html')
end
# This is a page that is needed in our application for integration with PicMonkey.
# It is built in our ember-cli project and deployed alongside `index.html`.
def picmonkey_done
render_page('picmonkey-done.html')
end