Skip to content

Instantly share code, notes, and snippets.

View ravibhure's full-sized avatar

Ravi ravibhure

View GitHub Profile
@ravibhure
ravibhure / chef_meta_parser.rb
Created September 11, 2014 03:50
Chef metadata parser to show dependancies
#!/usr/bin/env ruby
# @Author: Ravi Bhure <ravibhure@gmail.com>
require 'chef/cookbook/metadata'
metadata_file = ARGV.first || 'metadata.rb'
# read in metadata
metadata = Chef::Cookbook::Metadata.new
metadata.from_file(metadata_file)
@ravibhure
ravibhure / python_resource.md
Last active August 29, 2015 14:06
Just an example
  1. Create new cookbook example

     knife cookbook create example
    
  2. Create file name foo.py, Open Editor for examples/files/default/foo.py

     #!/usr/bin/python
     # Author: Sanjay Lokhande <sanjay.lokhande@opexsoftware.com>
    

import os

@ravibhure
ravibhure / db_backup.sh
Created October 14, 2014 06:54
Back up, compress and encrypt a small MySQL Database
#!/bin/bash
# Author: Ravi Bhure <ravibhure@gmail.com>
# Date: 13/10/2014
# This script dumps a "orders" database, compresses, encrypts and timestamps it, then saves it to netapp storage local mount. Ideal for a cronjob.
# It uses symmetric encryption, so guard your password carefully.
#
# NOT RECOMMENDED FOR LARGE DATABASES!
# Set your variable..
my_server=db.example.com
@ravibhure
ravibhure / jvm_tools.md
Created November 3, 2014 05:05
Some ( not all ) helpful tools the jvm provides out of the box
  • hprof a builtin java agent which dumps profiling info at runtime
  • class sharing class file cache used for faster startup times
  • pack200 unpack200 uber packed jars
  • mission control a Profiling, Monitoring, and Diagnostics Tools Suite
  • jstat performance stats tool
  • jhat heap dump browser
  • jmap memory maps
  • jstack prints stack trace of running process
@ravibhure
ravibhure / install_elasticsearch.sh
Last active August 29, 2015 14:14
Installing elasticsearch from source
#!/bin/bash
# Installing elasticsearch from source
# https://gist.github.com/rajraj/1556657#file-es-sh
# https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.0.2.tar.gz
cd ~
sudo yum -y install java-1.7.0-openjdk
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.1.zip
unzip elasticsearch-0.90.1.zip
@ravibhure
ravibhure / gibench.sh
Created January 29, 2015 10:03
A very crude and brutish disk benchmark running mkdir and git init 5,000 times.
# time sh gibench.sh
dir=gitemp
rm -rf $dir &> /dev/null
mkdir $dir
cd $dir
for (( c=1; c<=5000; c++ ))
do
mkdir $c
cd $c
@ravibhure
ravibhure / post.md
Last active August 29, 2015 14:15 — forked from jkeiser/post.md

Chef Metal and LXC: Best Friends!

Chef Metal now supports LXC! All the benefits of Metal, including idempotent, versioned, reusable cluster definitions can be realized. You can use LXC containers for testing, or you can use them as a part of your application stack. You can now write a Metal recipe like so:

chef-metal is still alpha software. People are experimenting with it and contributing to it, but it is still evolving.

require 'chef_metal_lxc'
@ravibhure
ravibhure / Chef Metal_Configuration_and_Drivers.md
Created February 19, 2015 04:42
Chef Metal, Configuration and Drivers

Chef Metal, Configuration and Drivers

As Chef Metal approaches 1.0, we've landed a huge configuration and driver interface improvement intended to enable:

  • A standard way to specify credentials and keys that keeps them out of recipes and allows them to be used in multiple places
  • External commands (like "metal execute") that can look up information and manage a node independent of the original Metal recipe
  • Environmental and directory-specific configuration
  • Make the drivers easily usable in test-kitchen and knife

Herein I want to talk about the Driver interface and how it is used by provisioning programs like the machine resource or kitchen, and driver implementors.

@ravibhure
ravibhure / README.md
Last active August 29, 2015 14:16 — forked from fnichol/README.md
Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

#!/usr/bin/perl
# HAProxy Performance Statistics
# by Steve Kamerman
#
# To use, pipe your HAProxy log with timing information (like "0/0/1/1/3 200") to
# this script. It will output min, max, med, avg and a latency distribution graph.
#
# Info on timing logging in HAProxy: http://code.google.com/p/haproxy-docs/wiki/TimingEvents
#