Skip to content

Instantly share code, notes, and snippets.

.resolved.marker > .icon {
opacity: 1 !important;
color: #333;
font-size: 1.5em;
}
data = [
// ["name","age","state"],
["Sam","20","VA"],
["Joe","20","VA"],
["Sally","18","MD"],
["Sam","24","FL"],
["Jake","12","CO"],
["Sue","49","MA"],
["Larry","55","CO"],
["Bob","99","WA"],
# Greetings SQL Guru!
#
# The task is to write code that mimics the computation of a few SQL queries.
# Don't worry, you don't have to write a parser! Just read in a comma delimited
# flat file 'input.txt' and output the results of the following queries:
#
# select state,count(*) from table group by state order by count(*) desc
# select round(avg(age),1) from table
# select state,round(avg(age),0) from table group by state order by avg(age)
# select state,round(avg(age),0) from table where age > 15 AND age < 55 group by state order by state
# Welcome to FizzBuzz!
#
# The task is to print out the numbers 1 through 100. The exception being the following:
#
# - If the number is divisible by 3, print Fizz
# - If the number is divisible by 5, print Buzz
# - If the number is divisible by 3 and 5, print FizzBuzz
#
# You can write the solution in any language provided that any compilation or setup is
# done in the 'build' script and the command to run the solution is named 'fizzbuzz'.
@derekharmel
derekharmel / gist:c71484178283b336bf48
Created August 1, 2014 20:06
Bash function for tailing storm logs
# Example usage:
# storm-logs nimbus supervisor drpc
# storm-logs workers
function storm-logs() {
cmd="multitail"
for log in $@; do
case $log in
workers)
cmd="$cmd -ts -i /var/log/storm/worker-670*.log"
;;
@derekharmel
derekharmel / gist:6239651
Created August 15, 2013 09:45
Create an irb session that can access local variables from the startup script
#!/usr/bin/env ruby
require 'irb'
foo = 'bar'
IRB.setup(nil)
irb = IRB::Irb.new(nil)
IRB.conf[:MAIN_CONTEXT] = irb.context
irb.context.workspace = IRB::WorkSpace.new(binding)
@derekharmel
derekharmel / gist:6010084
Created July 16, 2013 16:03
zookeeper and kafka launch agents
> pwd
/Users/dharmel/Library/LaunchAgents
> more kafka.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@derekharmel
derekharmel / .ackrc
Created December 11, 2012 21:56
.ackrc for Rails projects that may use HAML, ERB, CoffeeScript, Sass, SCSS, Cucumber
--type-add=ruby=.haml,.rake,.rsel,.builder
--type-add=html=.html.erb,.html.haml
--type-add=js=.js.erb,.coffee
--type-add=css=.sass,.scss
--type-set=cucumber=.feature
--ignore-dir=vendor
--ignore-dir=log
--ignore-dir=tmp
--ignore-dir=doc
--ignore-dir=coverage
@derekharmel
derekharmel / gist:3795270
Created September 27, 2012 17:27
The best thing about still supporting a Rails 1.2 app
> time ./script/runner 'puts "So fast"'
So fast
real 0m0.984s
user 0m0.815s
sys 0m0.141s
@derekharmel
derekharmel / gist:3077371
Created July 9, 2012 16:10
Eventmachine and FiberIterator processing N requests per second with variable concurrency
require 'rubygems'
require 'em-synchrony'
require 'em-synchrony/fiber_iterator'
EM.synchrony do
values = (1..16).to_a
{a: 2, b: 4, c: 8}.each do |label,concurrency|
print "\n #{label}"
EM::Synchrony::FiberIterator.new(values, concurrency).each do |val|