Skip to content

Instantly share code, notes, and snippets.

@chaityacshah
chaityacshah / Spark aggregateByKey
Created October 23, 2019 18:58 — forked from tmcgrath/Spark aggregateByKey
Spark aggregateByKey example
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/___/ .__/\_,_/_/ /_/\_\ version 1.1.0
/_/
Using Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_65)
Type in expressions to have them evaluated.
Type :help for more information.
@chaityacshah
chaityacshah / multiple_ssh_setting.md
Created September 18, 2019 03:13 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@chaityacshah
chaityacshah / custom.css
Created August 25, 2018 02:33 — forked from ChrisBeaumont/custom.css
Demystifying Python Descriptors
<style>
@font-face {
font-family: "Computer Modern";
src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf');
}
div.cell{
width:800px;
margin-left:16% !important;
margin-right:auto;
}
from scipy.cluster.hierarchy import dendrogram, linkage
import sys
import matplotlib
matplotlib.use("Qt5Agg")
import numpy as np
from numpy import arange, sin, pi
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
from matplotlib import pyplot as plt
@chaityacshah
chaityacshah / Linear_Regression_Python
Created July 1, 2018 19:27 — forked from aswalin/Linear_Regression_Python
Understanding the difference between R_squared and Adjusted R_squared
import numpy as np
import pandas as pd
from sklearn import datasets, linear_model
def metrics(m,X,y):
yhat = m.predict(X)
print(yhat)
SS_Residual = sum((y-yhat)**2)
SS_Total = sum((y-np.mean(y))**2)
r_squared = 1 - (float(SS_Residual))/SS_Total
@chaityacshah
chaityacshah / safari-open-pages.py
Last active June 29, 2018 20:04 — forked from aleks-mariusz/safari-open-pages.py
This script fetches the current open tabs in all Safari windows. Useful to run remotely on your mac when you are at work and want to read a page you have open (remotely) at home but don't remember the url but can log in to your home system on the command line
#!/usr/bin/python
#
# This script fetches the current open tabs in all Safari windows.
# Useful to run remotely on your mac when you are at work and want
# to read a page you have open (remotely) at home but don't remember
# the url but can log in to your home system on the cmmand line
#
import sys
from pprint import pprint
@chaityacshah
chaityacshah / git_newrepo
Created September 28, 2017 04:17 — forked from c0ldlimit/git_newrepo
Git: Push a new or existing repo to Github
# Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/c0ldlimit/vimcolors.git
git push -u origin master
# Push an existing repository from the command line
@chaityacshah
chaityacshah / cleaning_data.R
Created September 27, 2017 14:07 — forked from t-redactyl/cleaning_data.R
Code associate with blog post
mtcars$am.f <- as.factor(mtcars$am); levels(mtcars$am.f) <- c("Automatic", "Manual")
mtcars$cyl.f <- as.factor(mtcars$cyl); levels(mtcars$cyl.f) <- c("4 cyl", "6 cyl", "8 cyl")
mtcars$vs.f <- as.factor(mtcars$vs); levels(mtcars$vs.f) <- c("V engine", "Straight engine")
mtcars$gear.f <- as.factor(mtcars$gear); levels(mtcars$gear.f) <- c("3 gears", "4 gears", "5 gears")
mtcars$carb.f <- as.factor(mtcars$carb)
@chaityacshah
chaityacshah / centred_chart.R
Created September 27, 2017 14:07 — forked from t-redactyl/centred_chart.R
Code associated with blog post
library(ggplot2); library(gridExtra)
g1 <- ggplot(data=mtcars, aes(x=wt, y=mpg)) +
geom_point(alpha = 0.7, colour = "#0971B2") +
ylab("Miles per gallon") +
ylim(10, 35) +
xlab("Weight (`000 lbs)") +
ggtitle("Untransformed Weight") +
geom_vline(xintercept = 0) +
theme_bw()
av_peds_2 <- ddply(p.subset, c("date", "collapsed_sensors_2"), summarise,
n_peds = sum(Hourly_Counts))
# Extract weekday versus weekend
av_peds_2$day <- weekdays(av_peds_2$date, abbreviate = FALSE)
av_peds_2$weekend <- ifelse((av_peds_2$day == "Saturday" | av_peds_2$day == "Sunday"),
"Weekend", "Weekday")
av_peds_2$weekend <- as.factor(av_peds_2$weekend)
# Extract time of day