Skip to content

Instantly share code, notes, and snippets.

puts "You did read the source before blinding running it, right?"
def fancy_method
puts "That was fun"
end

PostgreSQL Replication

PostgreSQL takes the replication strategy of MySQL and breaks it into two pieces:

  • Streaming Replication
  • Log Shipping Replication

While MySQL combines both of those into a single process, PostgreSQL splits them

(function() {
$(document).on('ready page:load', function() {
$('#tabs').tabs();
// Setup an event handler to add tab clicks to the browser's history. This makes
// the back and forward buttons navigate through the tabs. Note: this doesn't
// handle keyboard navigation of the tabs. That's probably OK, since the tabs
// have special handling for keyboard navigation built in, and back/forward
// doesn't really make sense in that context.
$('ul.ui-tabs-nav a').on('click', function() {
var href = $(this).attr('href');
namespace :db do
desc 'kills connections to postgres db'
task :kill_postgres_connections => :environment do
puts "WARN: killing connections to #{ActiveRecord::Base.connection_config[:database]}."
ActiveRecord::Base.connection.execute("SELECT pid, pg_terminate_backend(pid) as terminated FROM pg_stat_activity WHERE pid <> pg_backend_pid()")
end
desc 'Alias for :kill_postgres_connections'
task :kill => :kill_postgres_connections
@masonjm
masonjm / zpl armband
Created May 23, 2014 19:52
Example of printing an armband to a ZPL printer.
class Armband
def initialize(encounter, options = {})
@encounter = encounter
end
def to_zpl(format)
# Units are in dots
zpl = "^XA" # ZPL Begin
zpl << "^LH0,0" # Home position X, Y
zpl << "^PON" # Print orientation normal
@masonjm
masonjm / depends_on.js
Created May 22, 2014 00:43
Show/Hide form fields based on the value in another field.
(function( $ ){
$.fn.dependsOn = function(element, value) {
var elements = this;
var hideOrShow = function() {
var $this = $(this);
var showEm;
if ( $this.is('input[type="checkbox"]') ) {
showEm = $this.is(':checked');
} else if ($this.is('select')) {