Skip to content

Instantly share code, notes, and snippets.

Simon Chiang thinkerbot

  • Denver, CO
Block or report user

Report or block thinkerbot

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
thinkerbot / Vagrantfile
Created Jan 29, 2014
Kafka round trip perf test
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at
View dance_moves.rb
#!/usr/bin/env ruby
# ruby dance_moves.rb
string = "get down"
def dance(move, string)
string = string.send(move)
print "%s\r" % string
sleep 0.3

I'm going to do my best to parrot things I picked up from the scala course... What you've done here by declaring functions with {} works but I don't think it is the intended syntax. Odersky presented it like this:

() is how you call a function, ie they wrap parameters just like you would expect. If one parameter is a function literal then you get the a form like this:

val nums = List(0,1,0)                          //> nums  : List[Int] = List(0, 1, 0) => {x.toString})                   //> res0: List[String] = List(0, 1, 0)

Note: cqlsh converts timestamps into current timezone

You can prove this manually:

$ cqlsh
cqlsh> CREATE KEYSPACE mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
cqlsh> use mykeyspace;
cqlsh> CREATE TABLE objects (id int PRIMARY KEY, name text, date timestamp);
cqlsh> INSERT INTO objects (id, name, date) VALUES (1, 'one', '2010-01-01T00:00:00Z');
cqlsh> SELECT * FROM objects;
View schema_scope.sql
drop schema if exists a cascade;
create schema a;
drop schema if exists b cascade;
create schema b;
create table b.things (id int);
insert into b.things (id) values (1);
insert into b.things (id) values (2);
insert into b.things (id) values (3);


Starting/stopping processes occurs in serial, ergo make sure the start/stop commands go quickly or the whole thing hangs. I It's a good idea to use scripts to setup the execution environment so you have something fully reproducible. Here is the command to get the ruby environment via rvm.

rvm info environment | sed -n -e 's/: \{1,\}/=/' -e 's|.rvm/bin:.*|.rvm/bin:$PATH"|' -e 's/    \([A-Z]\)/export \1/p'

An example usage:

check process process_name with pidfile /path/to/
  start program = "/usr/bin/env -i KEY=VALUE /path/to/ /path/to/monit_exec start /path/to/ /path/to/stdin_file /path/to/stdout_file /path/to/logfile.log commmand args..."
thinkerbot / xyz.cql
Created Aug 26, 2014
Examples of cql queries
View xyz.cql
CREATE KEYSPACE example WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
USE example;
create table xyz (
xpart int,
x int,
z int,
y int,
thinkerbot / pipe-exec
Last active Aug 29, 2015
Hold open a fifo from both ends, allowing input from external processes
View pipe-exec
#!/usr/bin/env ruby
require 'optparse'
options = {
:direction => "in"
} do |opts|
opts.banner = %{
usage: pipe-exec [options] FIFO_FILE COMMAND....

RSpec issues with include

We're extracting modules from intellisource and that's a good engineering practice. We can localize and document the footprint of modules by requiring and including them where they're used.

module HelperModule
  class HelperClass
thinkerbot /
Last active Aug 29, 2015
Clean merge

One way to merge nested configs cleanly:

  • flatten key paths
  • merge

This approach overcomes the issue of performing a deep merge when an overlay has the ability to specify a value or a hash. This does not deal with merging array values.

Here is the issue:

c1 = {"a" => 1}
You can’t perform that action at this time.