Skip to content

Instantly share code, notes, and snippets.

$LOAD_PATH.unshift File.dirname(__FILE__) + '/..'
require 'rubyrep'
module RR
# Some helper functions that are of use to all TableScan classes
module TableScanHelper
# Compares the primary keys of left_row and right_row to determine their rank.
# Assumes there is a function primary_key_names returning the array of primary keys
@alehmann
alehmann / myapp_rep
Created November 12, 2009 03:43
rubyrep: system startup script
#! /bin/sh
#
# /etc/init.d/myapp_rep.sh
#
# chkconfig: 35 99 99
# description: Starts or stops the myapp replication
#
# Assumes that application specific files
# * replication launcher script
# * rubyrep configuration file
@alehmann
alehmann / gist:316522
Created February 27, 2010 06:30
rubyrep / postgres: syncing tables with circular foreign key constraints
psql postgres -c "create database circular_fkeys_left"
psql circular_fkeys_left <<EOS
create table foos(id integer primary key, bar_id integer);
create table bars(id integer primary key, foo_id integer);
insert into foos(id, bar_id) values(1, 5);
insert into bars(id, foo_id) values(5, 1);
alter table foos add constraint bar_fk foreign key(bar_id) references bars;
alter table bars add constraint foo_fk foreign key(foo_id) references foos;
EOS
@alehmann
alehmann / hg-git-keyerror.sh
Created April 1, 2010 05:50
Script to reproduce hg-git KeyError exception and suggested fix
#!/bin/sh
# This script tests the following repo workflow:
#
# git-mirror -- clone --> git-contribs
# ^ /
# | /
# push pull
# | /
# hg-main <------------/
@alehmann
alehmann / context.rb
Last active April 18, 2018 03:31
Overriden ransack evaluate method in context.rb to support simple custom sort scopes
# A custom initializer that enables sorting via custom scopes in Ransack (like the same feature in MetaSearch)
module Ransack
module Adapters
module ActiveRecord
class Context < ::Ransack::Context
# Allows for sorting by custom scopes
#
#

Keybase proof

I hereby claim:

  • I am alehmann on github.
  • I am alehmann (https://keybase.io/alehmann) on keybase.
  • I have a public key ASBQeUnpXXTBOc5ctY4BN8N6WX-XMfBH_VUNMPnXlKU5mQo

To claim this, I am signing this object: