Skip to content

Instantly share code, notes, and snippets.

View P7h's full-sized avatar

Prashanth Babu P7h

  • London, UK
View GitHub Profile
@P7h
P7h / Primes.java
Last active August 29, 2015 13:59
Trivia: Generate primes between 1 and 100 million with Hadoop MapReduce job. Inspired by https://gist.github.com/krishnanraman/6346307.
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
@P7h
P7h / CreateMissingFiles.py
Created May 12, 2014 16:44
Python utility to create missing tsv files [numbered 1 to 78] in a directory.
import os
folder_name = 'D:/issue/'
for i in range(1, 79):
fileName = folder_name + str(i) + ".tsv"
if not os.path.isfile(fileName):
with open(fileName, 'w') as f:
f.write('word\tcount\n')
f.close()
@P7h
P7h / ShutFirewall.sh
Last active August 29, 2015 14:01
Turn off the firewall on a Linux machine
sudo service iptables save
sudo service iptables stop
sudo chkconfig iptables off
# Ubuntu
sudo ufw status
sudo ufw off
@P7h
P7h / LifeExpectancyAtBirth.csv
Last active August 29, 2015 14:17
Life expectancy at birth
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 55 columns, instead of 13. in line 3.
CountryName,CountryCode,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012
Aruba,ABW,65.57,65.99,66.37,66.71,67.04,67.37,67.70,68.03,68.38,68.73,69.09,69.45,69.80,70.14,70.47,70.78,71.08,71.38,71.67,71.95,72.22,72.46,72.67,72.85,72.99,73.10,73.18,73.24,73.30,73.34,73.39,73.43,73.47,73.51,73.54,73.56,73.59,73.61,73.64,73.68,73.72,73.78,73.87,73.97,74.09,74.23,74.38,74.53,74.67,74.82,74.95,75.08,75.21
Afghanistan,AFG,31.58,32.10,32.61,33.13,33.64,34.15,34.66,35.17,35.67,36.17,36.66,37.14,37.61,38.07,38.52,38.97,39.41,39.85,40.29,40.75,41.23,41.76,42.34,42.96,43.64,44.38,45.17,46.00,46.85,47.71,48.57,49.40,50.21,50.99,51.71,52.38,52.97,53.51,53.99,54.43,54.85,55.26,55.67,56.11,56.57,57.06,57.57,58.09,58.61,59.11,59.60,60.07,60.51
Angola,AGO,32.98,33.39,33.79,34.19,34.59,34.99,35.40,35.80,36.21,36.61,37
@P7h
P7h / LifeExpectancyAtBirth.csv
Last active August 29, 2015 14:18
Life expectancy at birth - Module 3 exercise
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 55 columns, instead of 13. in line 3.
CountryName,CountryCode,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012
Aruba,ABW,65.57,65.99,66.37,66.71,67.04,67.37,67.70,68.03,68.38,68.73,69.09,69.45,69.80,70.14,70.47,70.78,71.08,71.38,71.67,71.95,72.22,72.46,72.67,72.85,72.99,73.10,73.18,73.24,73.30,73.34,73.39,73.43,73.47,73.51,73.54,73.56,73.59,73.61,73.64,73.68,73.72,73.78,73.87,73.97,74.09,74.23,74.38,74.53,74.67,74.82,74.95,75.08,75.21
Afghanistan,AFG,31.58,32.10,32.61,33.13,33.64,34.15,34.66,35.17,35.67,36.17,36.66,37.14,37.61,38.07,38.52,38.97,39.41,39.85,40.29,40.75,41.23,41.76,42.34,42.96,43.64,44.38,45.17,46.00,46.85,47.71,48.57,49.40,50.21,50.99,51.71,52.38,52.97,53.51,53.99,54.43,54.85,55.26,55.67,56.11,56.57,57.06,57.57,58.09,58.61,59.11,59.60,60.07,60.51
Angola,AGO,32.98,33.39,33.79,34.19,34.59,34.99,35.40,35.80,36.21,36.61,37
@P7h
P7h / Sacramento_yearly_tavg.csv
Created April 5, 2015 05:17
Long term (1915-2011) average temperature data for location near Sacramento CA
year tavg
1915 15.877928353357
1916 15.3372481890357
1917 15.9840830951421
1918 15.6915538950237
1919 15.2778507456605
1920 15.2137783316169
1921 16.0093164519457
1922 15.3403901730479
1923 15.7414461778962
@P7h
P7h / LifeExpectancyAtBirth.csv
Last active August 29, 2015 14:18
Life expectancy at birth - Module 4 exercise
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 55 columns, instead of 13. in line 3.
CountryName,CountryCode,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012
Aruba,ABW,65.57,65.99,66.37,66.71,67.04,67.37,67.70,68.03,68.38,68.73,69.09,69.45,69.80,70.14,70.47,70.78,71.08,71.38,71.67,71.95,72.22,72.46,72.67,72.85,72.99,73.10,73.18,73.24,73.30,73.34,73.39,73.43,73.47,73.51,73.54,73.56,73.59,73.61,73.64,73.68,73.72,73.78,73.87,73.97,74.09,74.23,74.38,74.53,74.67,74.82,74.95,75.08,75.21
Afghanistan,AFG,31.58,32.10,32.61,33.13,33.64,34.15,34.66,35.17,35.67,36.17,36.66,37.14,37.61,38.07,38.52,38.97,39.41,39.85,40.29,40.75,41.23,41.76,42.34,42.96,43.64,44.38,45.17,46.00,46.85,47.71,48.57,49.40,50.21,50.99,51.71,52.38,52.97,53.51,53.99,54.43,54.85,55.26,55.67,56.11,56.57,57.06,57.57,58.09,58.61,59.11,59.60,60.07,60.51
Angola,AGO,32.98,33.39,33.79,34.19,34.59,34.99,35.40,35.80,36.21,36.61,37
@P7h
P7h / FoodDataFinal.csv
Created April 7, 2015 22:51
Food data height issue -- KnightD3 MOOC
Country Rank Score ScoreReversedHighGood UndernourishmentStandard UnderweightStandard EnoughtoEatScore EnoughtoEatScoreReversed FoodPriceLevelStandard FoodPriceInflationStandard AffordScore AffordScoreReversed NutritionDiversityStandard SafeWaterStandard FoodQualityScore FoodQualityScoreReversed DiabetesStandard ObesityStandard UnhealthyEatingScore UnhealthyEatingScoreReversed RawUndernourish RawUnderweight RawFoodPrice RawInflationVolatility RawDietDiversity RawSafeWater RawDiabetes RawObesity Code Region Incomegroup Driver1 Driver2 Driver3 DriverBest DriverBestF Driver1a Driver2a Driver3a DriverWorst DriverWorstF
Netherlands 1 6 94 0 0 0 100 6 7 7 93 3 0 2 98 9 25 17 83 13.3 16.6 2.02 0.039440707 57 74.4 8.8 10.3 NLD Europe & Central Asia High income: OECD 100 100 100 100 Enough to Eat 7 7 17 17 Unhealthy Eating
France 2 8 92 0 0 0 100 14 3 9 91 10 0 5 95 12 24 18 82 4 0.9 2.03 0.082913198 45 97.8 6.3 7.7 FRA Europe & Central Asia High income: OECD 100 100 100 100 Enough to Eat 9 9 18 18 Unhealthy Eating
@P7h
P7h / LifeExpectancyAtBirth.csv
Last active August 29, 2015 14:19
Life expectancy at birth - Module 5 exercise [scatterplot]
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 55 columns, instead of 13. in line 3.
CountryName,CountryCode,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012
Aruba,ABW,65.57,65.99,66.37,66.71,67.04,67.37,67.70,68.03,68.38,68.73,69.09,69.45,69.80,70.14,70.47,70.78,71.08,71.38,71.67,71.95,72.22,72.46,72.67,72.85,72.99,73.10,73.18,73.24,73.30,73.34,73.39,73.43,73.47,73.51,73.54,73.56,73.59,73.61,73.64,73.68,73.72,73.78,73.87,73.97,74.09,74.23,74.38,74.53,74.67,74.82,74.95,75.08,75.21
Afghanistan,AFG,31.58,32.10,32.61,33.13,33.64,34.15,34.66,35.17,35.67,36.17,36.66,37.14,37.61,38.07,38.52,38.97,39.41,39.85,40.29,40.75,41.23,41.76,42.34,42.96,43.64,44.38,45.17,46.00,46.85,47.71,48.57,49.40,50.21,50.99,51.71,52.38,52.97,53.51,53.99,54.43,54.85,55.26,55.67,56.11,56.57,57.06,57.57,58.09,58.61,59.11,59.60,60.07,60.51
Angola,AGO,32.98,33.39,33.79,34.19,34.59,34.99,35.40,35.80,36.21,36.61,37
@P7h
P7h / LifeExpectancyAtBirth.csv
Created April 18, 2015 22:19
Life expectancy at birth - Module 5 exercise [slopegraph]
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 55 columns, instead of 13. in line 3.
CountryName,CountryCode,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012
Aruba,ABW,65.57,65.99,66.37,66.71,67.04,67.37,67.70,68.03,68.38,68.73,69.09,69.45,69.80,70.14,70.47,70.78,71.08,71.38,71.67,71.95,72.22,72.46,72.67,72.85,72.99,73.10,73.18,73.24,73.30,73.34,73.39,73.43,73.47,73.51,73.54,73.56,73.59,73.61,73.64,73.68,73.72,73.78,73.87,73.97,74.09,74.23,74.38,74.53,74.67,74.82,74.95,75.08,75.21
Afghanistan,AFG,31.58,32.10,32.61,33.13,33.64,34.15,34.66,35.17,35.67,36.17,36.66,37.14,37.61,38.07,38.52,38.97,39.41,39.85,40.29,40.75,41.23,41.76,42.34,42.96,43.64,44.38,45.17,46.00,46.85,47.71,48.57,49.40,50.21,50.99,51.71,52.38,52.97,53.51,53.99,54.43,54.85,55.26,55.67,56.11,56.57,57.06,57.57,58.09,58.61,59.11,59.60,60.07,60.51
Angola,AGO,32.98,33.39,33.79,34.19,34.59,34.99,35.40,35.80,36.21,36.61,37