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
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!
VAGRANTFILE_API_VERSION = "2"
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 vagrantup.com.
View dance_moves.rb
#!/usr/bin/env ruby
# ruby dance_moves.rb
$stdout.sync
string = "get down"
def dance(move, string)
string = string.send(move)
print "%s\r" % string
sleep 0.3
View parens_vs_braces.md

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)
nums.map((x) => {x.toString})                   //> res0: List[String] = List(0, 1, 0)
View cqlsh_tz_note.md

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);
View README.md

Notes

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 env.sh 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/pidfile.pid
  start program = "/usr/bin/env -i KEY=VALUE /path/to/env.sh /path/to/monit_exec start /path/to/pidfile.pid /path/to/stdin_file /path/to/stdout_file /path/to/logfile.log commmand args..."
@thinkerbot
thinkerbot / xyz.cql
Created Aug 26, 2014
Examples of cql queries
View xyz.cql
DROP KEYSPACE IF EXISTS example;
CREATE KEYSPACE example WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
USE example;
DROP TABLE IF EXISTS xyz;
create table xyz (
xpart int,
x int,
z int,
y int,
@thinkerbot
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
begin
require 'optparse'
options = {
:direction => "in"
}
OptionParser.new do |opts|
opts.banner = %{
usage: pipe-exec [options] FIFO_FILE COMMAND....
View README.md

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.

[helper-module.gem]
module HelperModule
  class HelperClass
@thinkerbot
thinkerbot / README.md
Last active Aug 29, 2015
Clean merge
View README.md

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.