Skip to content

Instantly share code, notes, and snippets.

View amalgjose's full-sized avatar
🎯
Focusing

Amal G Jose amalgjose

🎯
Focusing
View GitHub Profile
@amalgjose
amalgjose / EmrLauncher
Last active July 23, 2021 15:34
Python code for launching an EMR cluster
__author__ = 'Amal G Jose'
import time
import logging
from boto.emr.connection import EmrConnection
from boto.emr.bootstrap_action import BootstrapAction
from boto.emr.step import InstallHiveStep
from boto.emr.step import InstallPigStep
from boto.regioninfo import RegionInfo
@amalgjose
amalgjose / GetAllInstances.py
Last active October 3, 2017 19:42
Python Program for getting all the details of running instances and tagging the instances
__author__ = 'Amal G Jose'
import sys
import boto
class GetAllInstances(object):
def __init__(self):
self.aws_access_key = 'XXXXXXXXXXXXXXX'
self.aws_secret_key = 'XXXXXXXXXXXXXXX'
if self.aws_access_key == '' or self.aws_secret_key == '':
@amalgjose
amalgjose / FileMultiplier.sh
Created November 19, 2014 11:33
Shell script for multiplying a file
#!/bin/bash
count=1
limit=10
while [ $count -le $limit ]
do
cat A.txt >> B.txt
cat B.txt >> A.txt
@amalgjose
amalgjose / CreateSnappy
Created November 21, 2014 10:48
Java program to compress a file in snappy. This compressed file can be used in hadoop, because the libraries used in this program are taken from hadoop.
package com.snappy.codec;
/*
* @author : Amal G Jose
*
*/
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@amalgjose
amalgjose / SkipMapper.java
Created November 24, 2014 09:18
Mapreduce program for removing stop words from the given text files. Hadoop Distributed cache and counters are used in this program
package com.hadoop.skipper;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
import org.apache.hadoop.fs.Path;
@amalgjose
amalgjose / GPSValues.py
Last active February 5, 2023 02:49
Sample python program to find the gps coordinates
__author__ = 'Amal G Jose'
import time
import serial
import string
from pynmea import nmea
ser = serial.Serial()
# Reading serial data from COM5 port. Change this port according to your settings.
ser.port = "COM5"
@amalgjose
amalgjose / DateDifference.py
Last active January 4, 2022 19:02
This is a very simple python code snippet for calculating the difference between two dates or timestamps. This will calculate the difference in terms of number of years, months, days, hours, minutes etc. For more details, refer https://amalgjose.com/2015/02/19/python-code-for-calculating-the-difference-between-two-time-stamps/
__author__ = 'Amal G Jose'
from datetime import datetime
from dateutil import relativedelta
##Aug 7 1989 8:10 pm
date_1 = datetime(1989, 8, 7, 20, 10)
##Dec 5 1990 5:20 am
date_2 = datetime(1990, 12, 5, 5, 20)
@amalgjose
amalgjose / HelloTornado.py
Last active August 29, 2015 14:15
Simple python tornado application
__author__ = 'Amal G Jose'
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
define("port", default=8888, help="run on the user defined port", type=int)
@amalgjose
amalgjose / ListCountMethod1.py
Created March 6, 2015 16:13
Method for finding the count of unique elements in a list. This will work only in python versions 2.7 and above
__author__ = 'Amal G Jose'
from collections import Counter
data_list = ['apple', 'apple', 'orange', 'mango', 'apple', 'grapes', 'banana', 'banana']
count = Counter(data_list)
print count.items()
print "Count of apple : ", count['apple']
print "Count of orange : ", count['orange']
@amalgjose
amalgjose / ListCountMethod2.py
Created March 6, 2015 16:19
Python method to find the count of unique elements in a list.
__author__ = 'Amal G Jose'
count = {}
data_list = ['apple', 'apple', 'orange', 'mango', 'apple', 'grapes', 'banana', 'banana']
for value in data_list:
if value in count.keys():
count[value] += 1
else:
count[value] = 1