Skip to content

Instantly share code, notes, and snippets.

Avatar

Suman srs81

  • USA
View GitHub Profile
View hbase_count_rows.py
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 Jul 14, 2020
Export all data from HBase database to CSV in this format: row-key, column-key, value
View hbase_export_csv.py
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 Dec 10, 2015
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"
View 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 Dec 5, 2012
Attach, format and mount a new EBS volume on an EC2 instance
View ec2_mount.sh
# 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 Oct 15, 2012
Sample boto AWS Glacier connection/upload/delete code
View glacier_layer2.py
# 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 Sep 26, 2012
Python: Run new EC2 instances, giving them names and assigning IP addresses
View runEC2instances.py
#!/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 Aug 10, 2012
Python: Auto start and stop EC2 instances at certain times of the day
View ec2_auto_stop_start.py
#!/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 Aug 2, 2012
Find cumulative+average cost for EC2 spot instances at time ranges
View ec2_spot_prices_total.py
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 Jul 30, 2012
Create a new user and give them access through SSH public/private keys
View linux_user_keys.sh
# 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 Jul 24, 2012 — forked from bbeck/setup.sh
Setup Asgard on Ubuntu 12.04
View asgard_setup.sh
#################
# Update packages
#################
sudo yum -y update
sudo yum -y upgrade
########################
# Install the Oracle JDK
########################