Skip to content

Instantly share code, notes, and snippets.

View srs81's full-sized avatar

Suman srs81

  • USA
View GitHub Profile
@srs81
srs81 / android_version_model.py
Created May 3, 2012 21:32
From useragent => find Android version, model, device (tablet/phone)
#
# Given a useragent string, return these results:
# Android version, device model name, type (tablet/phone)
#
import re
def android_details (useragent):
result = {}
result["aVersion"] = "Other"
result["amake"] = "Other"
@srs81
srs81 / mongo_shard.sh
Created May 24, 2012 17:26
Bash script to start mongod and sharded server on EC2 instance
# Create required directories
sudo mkdir /data
sudo mkdir /data/db
sudo mkdir /data/configdb
sudo mkdir /data/logs
# Give correct permissions
sudo chown -R ec2-user:ec2-user /data
# Start mongod server and shard server
@srs81
srs81 / happybase_test_put_counter.py
Created May 30, 2012 22:49
Python code to test HappyBase library (HBase), and counter and put speeds
import happybase
import time, random
# Number of test iterations
ITERATIONS = 10000
# Make the HBase connection
connection = happybase.Connection()
# Create the test table, with a column family
@srs81
srs81 / delete.py
Created July 10, 2012 17:54
Python script with Happybase to disable/delete all tables in HBase
import happybase
c = happybase.Connection()
for t in c.tables():
c.disable_table(t)
c.delete_table(t)
print (t + " deleted")
@srs81
srs81 / hbase_performance.py
Created July 10, 2012 18:30
HBase write performance testing: including batching and number of threads
from multiprocessing import Pool
import happybase, os, random, base64, time, sys
# Total number of rows to be inserted
TOTAL_PUTS = 100000000
# Number of inserts that are in one batch operation
BATCH_PUTS = 10000
# Output is displayed after how many iterations
OUTPUT_ITERATIONS = 50000
# Number of simultaneous threads (actually processes)
@srs81
srs81 / mysql_insert_select_test.php
Created July 18, 2012 22:02
MySQL insert, select performance testing in PHP
<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "cake";
$con = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$con) die('Could not connect: ' . mysql_error());
mysql_select_db($dbname, $con);
@srs81
srs81 / aws_ec2_types.sh
Created July 18, 2012 22:08
AWS: Create new EC2 instances of all types
KEYNAME=Suman1
# Amazon EBS AMI
# AMI=ami-aecd60c7
# Ubuntu instance-store AMI
AMI=ami-012b8568
REGTYPES=( t1.micro m1.small m1.medium m1.large m1.xlarge c1.medium c1.xlarge m2.xlarge m2.2xlarge m2.4xlarge hi1.4xlarge )
CLUTYPES=( cc1.4xlarge cg1.4xlarge cc2.8xlarge )
@srs81
srs81 / aws_mysql_amazon.sh
Created July 18, 2012 22:08
AWS: script to set up MySQL on AWS (Amazon AMI)
sudo yum -y groupinstall "MySQL Database" "PHP Support"
sudo yum -y install php-mysql
sudo service mysqld start
mysql -u root -e "CREATE DATABASE cake"
wget https://raw.github.com/gist/3139201/6cc45f51c6fce82296a7080a33e800576879eacb/mysql_insert_select_test.php
php mysql_insert_select_test.php
@srs81
srs81 / aws_mysql_ubuntu.sh
Created July 19, 2012 17:13
AWS: script to set up MySQL on AWS (Ubuntu AMI)
sudo apt-get -y install mysql-server php5 php5-mysql
mysql -u root -e "CREATE DATABASE cake"
wget https://raw.github.com/gist/3139201/6cc45f51c6fce82296a7080a33e800576879eacb/mysql_insert_select_test.php
php mysql_insert_select_test.php
@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
########################