Skip to content

Instantly share code, notes, and snippets.

View ashrithr's full-sized avatar
🎯
Focusing

Ashrith Mekala ashrithr

🎯
Focusing
View GitHub Profile
@ashrithr
ashrithr / zsh_features.md
Created June 16, 2013 23:50
zsh features

Why I love zsh

  • Smarter completion. A few examples:
  • context sensitive -- if you have file "name1" and directory "name2", "cd nam<TAB>" completes to "name2/"
  • "tar xf <TAB>" completes to tarballs only. "unrar x <TAB>" completes to RARs only. etc.
  • rsync / scp completion: "rsync host:anything/<TAB>" shows you files on host under anything/
  • also works with rsync:// URLs
  • SSH host completion from ~/.ssh/config & ~/.ssh/known_hosts
  • lots of other smart completions: Rake tasks, git commands & SHAs, dpkg packages, dash-options for most commands, etc etc.
@ashrithr
ashrithr / kafka_twitter_producer.rb
Last active April 17, 2019 20:00
kafka twitter producer, dumps twitter firehose to kafka.
begin
require 'tweetstream'
require 'poseidon'
rescue 'LoadError'
raise "Requires tweetstream and poseidon libraries"
end
raise "Works only on 1.9" if RUBY_VERSION < "1.9"
raise "Requires Argument keyword to match from twitter firehose" if ARGV.length == 0
@ashrithr
ashrithr / Usage.md
Last active March 1, 2019 22:48
Ruby SSL Server

Sample TCP server-client implementation using openssl in ruby

Use the wrapper shell script to create ssl certificates ./openssl.sh -newca, enter the details and the required files will be generated to ./demoCA dir from where you run the script. cacert.pem will be your ssl-certificate and private/cakey.pem will be your ssl-key

Start SSL Server using:

ruby ssl_server.rb 9099 demoCA/cacert.pem demoCA/private/cakey.pem
@ashrithr
ashrithr / check_dfs.sh
Last active January 14, 2019 06:01
nagios plugin to monitor dfs
#!/usr/bin/env bash
# ---
# => Nagios plugin to monitor hadoop dfs
# This script serves as base line for nagios plugins for hadoop
# Author: Ashrith
# ---
PROGNAME=`basename $0`
VERSION="Version 1.0"
@ashrithr
ashrithr / check_hbase_onlineregions.sh
Created May 20, 2013 17:54
nagios plugin for hbase to check how many regions a region server is serving and throw critical if regions > 90
#!/usr/bin/env bash
#Author: Ashrith
#Arrays to store hosts and their regionsOnLine respectively
declare -a HOSTS_ARRAY
declare -a REGIONS_ARRAY
message=""
EXIT_STATUS=0
@ashrithr
ashrithr / csr.rb
Created June 20, 2013 05:10
ruby openssl
require 'openssl'
#
# Program to demonstrate Certificate Signing Request using openssl
#
# Create a new key
def gen_key(name)
key = OpenSSL::PKey::RSA.new 1024
file = File.new name, "w"
@ashrithr
ashrithr / flume-ng-agent.sh
Last active August 21, 2018 15:11
Custom Flume NG Agent INIT script for centos for runnig multiple agents on same machine
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@ashrithr
ashrithr / TwitterStreamExample.java
Created September 4, 2013 07:04
Twitter4j and GeoCode Parsing
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
@ashrithr
ashrithr / iperf.md
Created September 30, 2013 22:54
iperf usage

Start server on one machine using:

iperf -s -i 1
  • -i specifies the interval at which the output is specified
  • -s specified to start server

Start client on another machine using:

@ashrithr
ashrithr / undent.rb
Last active May 18, 2017 04:53
Ruby un-indent lines of here document
class String
def undent
gsub(/^.{#{slice(/^ +/).length}}/, '')
end
end
#Usage:
test = <<-EOS.undent
testing unindent
..another line