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 / 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 / jdk_download_old.sh
Created April 17, 2015 14:19
JDK Download script [earlier version] -- NOT maintaining this anymore. Please check: https://gist.github.com/P7h/9741922
# Commands to download JDK from shell.
# Not maintaining this anymore. Please check: https://gist.github.com/P7h/9741922
# http://stackoverflow.com/questions/10268583
# wget --no-check-certificate --no-cookies - --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
#JDK8u25
BASE_URL=http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25
@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
@P7h
P7h / LargestInSubArrayInAWindow.groovy
Last active April 14, 2016 21:57
Find the largest of a sub-array for a specific window size
int[] arr = [-1, 3, 1, 5,3 ,2 ,1, 0, 7];
int window = 3
int len = arr.length;
for(int i = 0; i< len-window+1; i += 1) {
int[] newarr = new int[window];
for(int j =0 ; j< window; j++){
newarr[j] = arr[i+j];
}
println(getMax(newarr))
@P7h
P7h / LifeExpectancyAtBirth.csv
Created April 25, 2015 00:40
Life expectancy at birth - Module 6 exercise [multi-linechart]
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 / cpu_info.py
Last active August 29, 2015 14:23
Python snippets for quickly finding the platform type, cpu and memory stats of a Linux machine.
###### CPU Info of a Linux machine.
### Picked from: http://echorand.me/site/notes/articles/python_linux/article.html
from __future__ import print_function
from collections import OrderedDict
import pprint
def cpuinfo():
cpuinfo=OrderedDict()
procinfo=OrderedDict()
nprocs = 0
@P7h
P7h / tmux.cheat
Last active February 7, 2019 15:38 — forked from afair/tmux.cheat
========================================== ==========================================
TMUX COMMAND WINDOW (TAB)
========================================== ==========================================
List tmux ls List ^b w
New -s <session> Create ^b c
Attach att -t <session> Rename ^b , <name>
Rename rename-session -t <old> <new> Last ^b l (lower-L)
Kill kill-session -t <session> Close ^b &
@P7h
P7h / jdk7_download.sh
Created July 17, 2015 08:29
JDK 7 command line download script; For JDK8, please check: https://gist.github.com/P7h/9741922
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
#### Command line download script for JDK7 from Oracle website.
#### For JDK8, please check: https://gist.github.com/P7h/9741922
#### Oracle does not release JDK 7 public updates effective April, 2015; for more info: http://www.oracle.com/technetwork/java/javase/documentation/eol-135779.html.
## Last JDK7 version: JDK7u79
BASE_URL_7=http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79
## Previous versions
@P7h
P7h / SparkML-QuickRef.md
Created March 24, 2016 10:12 — forked from jreuben11/SparkML-QuickRef.md
Spark.ml Pipelines QuickRef

in a nutshell: fit trainingData (train a model), transform testData (predict with model)

  • Transformer: DataFrame => DataFrame
  • Estimator: DataFrame => Transformer

#Transformers

  • Tokenizer: sentence => words
  • RegexTokenizer: sentence => words - setPattern
  • HashingTF: terms => feature vectors based on frequency - setNumFeatures