Skip to content

Instantly share code, notes, and snippets.

@chaityacshah
chaityacshah / pymac.md
Last active June 11, 2018 13:44
Python and Mac!

Python packages are installed in /Library/Python/2.7/site-packages by default.
To find the path programmatically,

from distutils.sysconfig import get_python_lib
print(get_python_lib())

Output:

/opt/anaconda/anaconda/lib/python3.5/site-packages

@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 / 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
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

factual.com

returns basic business info like name, location, etc.
disadv: only textual data. no restaurant logos

  • Search for restaurants by name, cuisine, or location
  • Display detailed information including ratings, location and cuisine
  • Use the Zomato Foodie Index to show great areas to dine in a city

Get/search returns URL of menu too.

@chaityacshah
chaityacshah / test_cases.md
Last active July 21, 2018 22:38
test cases for stackoverflow question

1

pprint.pprint(parse("(dog:20, (elephant:30, horse:60)eh:20)root:50"))

2

pprint.pprint(parse("(A:0.1,B:0.2,(C:0.3,D:0.4)E:0.5,G:0.8)F:0.9"))

3

pprint.pprint(parse("(ant:17, (bat:31, cow:22)bc:7, dog:22, (elk:33, fox:12)ef:40)root:1"))

4

pprint.pprint(parse("(Bovine:0.69395,(Gibbon:0.36079,(Orang:0.33636,(Gorilla:0.17147,(Chimp:0.19268, Human:0.11927)ch:0.08386)gch:0.06124)ggch:0.15057)oggch:0.54939,Mouse:1.21460)root:1"))

How can I remove a commit on GitHub?

git log  
git reset --hard ef2ef39d3c2842dd027b42fd96d7b3bc1db6e59d  
git push --force

2: git push -f origin HEAD^:master
3: git push origin +7f6d03:master

@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;
}