Skip to content

Instantly share code, notes, and snippets.

View shadabahmed's full-sized avatar
🦋

Shadab Ahmed shadabahmed

🦋
View GitHub Profile
class SkylineTree
attr_reader :root
def initialize(node_class = Node, start = nil, value = nil)
@node_class = node_class
@root = start && tree_type.new(start, value)
end
def add(range, value = nil)
if root
@shadabahmed
shadabahmed / logstash-suse
Last active March 16, 2017 18:19
Logstash init.d script and config file. Ubuntu script is borrowed from http://www.vmdoh.com/blog/centralizing-logs-lumberjack-logstash-and-elasticsearch SuSe script is for SLES. Just copy the script to /etc/init.d as logstash
#! /bin/sh
### BEGIN INIT INFO
# Provides: logstash
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
@shadabahmed
shadabahmed / logstash-cert.sh
Last active July 31, 2017 05:56
Lumberjack - init.d and config files. Copy the init.d script to /etc/init.d/lumberjack and add execute permissions. Copy the config file lumberjack to /etc/default/lumberjack file.
# Create Key
openssl genrsa -des3 -out logstash.key 1024
sudo openssl genrsa -des3 -out logstash.key 1024
# Create CSR
openssl req -new -key logstash.key -out logstash.csr
sudo openssl req -new -key logstash.key -out logstash.csr
# Remove password from key
sudo openssl rsa -in logstash.key.org -out logstash.key
# Create certificate
sudo openssl x509 -req -days 365 -in logstash.csr -signkey server.key -out logstash.crt
@shadabahmed
shadabahmed / aggrobot.rb
Created October 1, 2014 05:47
Aggrobot Example
=begin
{
"region1": {month1: {avg_target: xxx, avg_actual: xxx}
month2: .........
}
=end
@shadabahmed
shadabahmed / skip_list.rb
Created June 10, 2018 15:54
Skip List Ruby Implementation
INFINITY = 1.0 / 0
NEG_INFINITY = -1.0 / 0
class Node
MAX_LEVEL = 7
# node has value and levels
attr_accessor :val, :levels
def initialize(val)
self.val = val
self.levels = []