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 / rvm.md
Last active December 18, 2015 16:19
Install ruby using rvm

Installing ruby using rvm:

# On RedHat based systems
yum install curl

# On Debian based systems
apt-get install curl
@ashrithr
ashrithr / kafka.md
Last active March 14, 2024 21:16
kafka introduction

Introduction to Kafka

Kafka acts as a kind of write-ahead log (WAL) that records messages to a persistent store (disk) and allows subscribers to read and apply these changes to their own stores in a system appropriate time-frame.

Terminology:

  • Producers send messages to brokers
  • Consumers read messages from brokers
  • Messages are sent to a topic
@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 / 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 / install_puppet.sh
Created June 25, 2013 01:40
Script to install standalone puppet package
#!/usr/bin/env bash
# -
# Script to install standalone puppet
# -
OS=`uname -s`
REV=`uname -r`
MACH=`uname -m`
@ashrithr
ashrithr / sshable_function.sh
Created June 25, 2013 17:26
shell function to check if a instance is sshable (can be used for cloud instaces)
function sshable () {
[[ $# -ne 3 ]] && { echo "requires instance, ssh_user, ssh_key arguments"; return; }
instance=$1
ssh_user=$2
ssh_key=$3
command=$(ssh -t -t -o ConnectTimeout=2 -o StrictHostKeyChecking=no -o BatchMode=yes -o UserKnownHostsFile=/dev/null -p 22 -i ${ssh_key} ${ssh_user}@${instance} "echo" &>/dev/null)
until $command; do
echo -e ".\c"
done
echo ""
@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
@ashrithr
ashrithr / .gitconfig
Last active December 20, 2015 00:59
my git configuration with aliases
[user]
name = ashrithr
email = [email protected]
[color]
ui = auto
[credential]
helper = osxkeychain
[core]
excludesfile = /Users/ashrith/.gitignore_global
[difftool "sourcetree"]
@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