Skip to content

Instantly share code, notes, and snippets.

View srs81's full-sized avatar

Suman srs81

  • USA
View GitHub Profile
import happybase, sys, os, string
# VARIABLES
# HBase Thrift server to connect to. Leave blank for localhost
server = ""
# Connect to server
c = happybase.Connection(server)
# Get the full list of tables
@srs81
srs81 / hbase_export_csv.py
Last active July 14, 2020 13:19
Export all data from HBase database to CSV in this format: row-key, column-key, value
import happybase, sys, os, string
# VARIABLES
# Output directory for CSV files
outputDir = "/mnt"
# HBase Thrift server to connect to. Leave blank for localhost
server = ""
# Connect to server
c = happybase.Connection(server)
@srs81
srs81 / write_speed.php
Last active December 10, 2015 15:38
Test the speed of writing 10,000 random strings 100 times each (1,000,000 lines total) to disk. Run as "time php write_speed.php"
<?php
// Length of each line
$length = 40;
// Open up a file
$file = fopen("test.txt", "w");
// Generate 10,000 strings
for ($iii=0; $iii<=10000; $iii++) {
@srs81
srs81 / ec2_mount.sh
Created December 5, 2012 18:17
Attach, format and mount a new EBS volume on an EC2 instance
# Variables
VOLUME=/dev/sdf
DIRECTORY=/var/www/html/
USER=apache
GROUP=apache
# Commands
mkfs -t ext4 $VOLUME
mount $VOLUME $DIRECTORY
echo "$VOLUME $DIRECTORY ext4 noatime 0 0" | sudo tee -a /etc/fstab
@srs81
srs81 / glacier_layer2.py
Created October 15, 2012 22:57
Sample boto AWS Glacier connection/upload/delete code
# Author: Suman
# Import boto's layer2
import boto.glacier.layer2
# Various variables for AWS creds, vault name, local file name
awsAccess = "AKIAxxxx"
awsSecret = "YouRSecRetKeY"
vaultName = "YourVaultName"
fileName = "LocalFileName"
@srs81
srs81 / runEC2instances.py
Created September 26, 2012 17:29
Python: Run new EC2 instances, giving them names and assigning IP addresses
#!/usr/bin/python
#
# Start new EC2 instances
#
import boto, sys, time
print "Please enter your AWS credentials below."
# AWS credentials
@srs81
srs81 / ec2_auto_stop_start.py
Created August 10, 2012 21:01
Python: Auto start and stop EC2 instances at certain times of the day
#!/usr/bin/python
#
# Auto-start and stop EC2 instances
#
import boto, datetime, sys
from time import gmtime, strftime, sleep
# AWS credentials
aws_key = "AKIAxxx"
aws_secret = "abcd"
@srs81
srs81 / ec2_spot_prices_total.py
Created August 2, 2012 16:13
Find cumulative+average cost for EC2 spot instances at time ranges
import boto, datetime, time
# Enter your AWS credentials
aws_key = "YOUR_AWS_KEY"
aws_secret = "YOUR_AWS_SECRET"
# Details of instance & time range you want to find spot prices for
instanceType = 'm1.xlarge'
startTime = '2012-07-01T21:14:45.000Z'
endTime = '2012-07-30T23:14:45.000Z'
@srs81
srs81 / linux_user_keys.sh
Created July 30, 2012 14:54
Create a new user and give them access through SSH public/private keys
# Change to sudo
sudo su
# Export the username you want to create
export USERNAME=name
adduser $USERNAME
cd /home/$USERNAME
# Create the SSH keys
mkdir .ssh
@srs81
srs81 / asgard_setup.sh
Created July 24, 2012 17:39 — forked from bbeck/setup.sh
Setup Asgard on Ubuntu 12.04
#################
# Update packages
#################
sudo yum -y update
sudo yum -y upgrade
########################
# Install the Oracle JDK
########################