Skip to content

Instantly share code, notes, and snippets.

View sbailliez's full-sized avatar

Stephane B. sbailliez

View GitHub Profile
Customer customer = new Customer();
.... save customer ...
Card card = new Card(cardHref);
if (card.customer == null) {
card.associateToCustomer(customer);
}
Debit debit = card.debit(...);
DebitResult result = from(debit);
@sbailliez
sbailliez / gist:11268423
Created April 24, 2014 20:27
Scalyr RDS Postgresql log parser
{
lineGroupers: [
{
// groups line used to display stats
start: "^[^\\s]",
continueThrough: "^[\\s]+!"
},
{
// try to group lines that do have queries with text data containing newlines. Over simplification.
start: "^\\d+-\\d+-\\d+\\s+\\d+:\\d+:\\d+ UTC",
@sbailliez
sbailliez / gist:8876660
Created February 8, 2014 04:20
Provision vagrant with ssh keys, pem file, git config, aws config, etc...
#
# Allows copying ssh keys, directly to vagrant.. quick hack for my needs
#
# It is basically reading the file, encoding it in base64, pass it in the shell, decode it and write it
# in the file with the same name in /home/vagrant, chown it and set 600 permissions
def provision_home(config, from, to = nil, user = 'vagrant', permission = "600")
if File.exists?(File.join(Dir.home, from))
require "base64"
to = to.nil? ? "/home/vagrant/#{from}" : to
require 'etc'
ssh_user = Etc.getlogin
public_key_path = "~/.ssh/id_dsa.pub"
ssh_public_key = File.read(File.expand_path(public_key_path)).strip
Vagrant.configure("2") do |config|
....
config.vm.provision :shell, :inline => "cat >>/tmp/ssh_key_pub <<EOF\n#{ssh_public_key}\nEOF"
config.vm.provision :shell, :inline => "cat >>/tmp/ssh_user <<EOF\n#{ssh_user}\nEOF"