Skip to content

Instantly share code, notes, and snippets.

@nodo
nodo / create_storm_topology_intellij_idea.md
Last active January 18, 2016 22:34
Create Storm Topology with IntelliJ Idea

Create Storm Topology with IntelliJ Idea

These are the steps I followed to create a new topology from scratch using IntelliJ Idea version 14.1.5.

Basic Setup

  1. File -> New -> Project
  2. Select Java from the sidebar on the left and 1.7 as SDK
  3. Click next until you are asked for "project name" and "location". Insert them and click "next"
@nodo
nodo / maxsubsequence.rb
Created July 23, 2015 12:43
Different algorithms for the maximum continuous subsequence problem
require 'benchmark'
# O(n^3)
def maxsubsequence_superslow(ary)
max_sum = 0
(0..ary.size - 1).each do |i|
(i..ary.size - 1).each do |j|
sum = 0
# avoid every possible optimization :)
(i..j).each do |k|
@nodo
nodo / to_hist.rb
Created March 4, 2015 10:05
Monkeypatch Hash class: add a method to transform hash counters in histograms
class Hash
def to_hist(char = 'x')
max_key_length = self.keys.map(&:to_s).max_by(&:length).length
max_value = self.values.max
divisions = 0
while max_value > 120
max_value /= 10.0
divisions += 1
end
self.each do |key, value|