Skip to content

Instantly share code, notes, and snippets.

@chaityacshah
chaityacshah / pycharm.md
Created May 28, 2018 18:42
Resetting pycharm settings on macOS

rm -rf ~/Library/Preferences/<PRODUCT><VERSION>/
rm -rf ~/Library/Caches/<PRODUCT><VERSION>/
rm -rf ~/Library/Application\ Support/PyCharmCE2018.1/
rm -rf ~/Library/Logs/PyCharmCE2018.1/

@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
1. Number of times pregnant 2. Plasma glucose concentration a 2 hours in an oral glucose tolerance test 3. Diastolic blood pressure (mm Hg) 4. Triceps skin fold thickness (mm) 5. 2-Hour serum insulin (mu U/ml) 6. Body mass index (weight in kg/(height in m)^2) 7. Diabetes pedigree function 8. Age (years) 9. Class variable (0 or 1)
6 148 72 35 0 33.6 0.627 50 1
1 85 66 29 0 26.6 0.351 31 0
8 183 64 0 0 23.3 0.672 32 1
1 89 66 23 94 28.1 0.167 21 0
0 137 40 35 168 43.1 2.288 33 1
5 116 74 0 0 25.6 0.201 30 0
3 78 50 32 88 31.0 0.248 26 1
10 115 0 0 0 35.3 0.134 29 0
2 197 70 45 543 30.5 0.158 53 1

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"))