Skip to content

Instantly share code, notes, and snippets.

@sidharthshah
sidharthshah / simple-crawler.py
Created August 7, 2019 10:10
Python Crawling Example
import re
import ssl
from urllib import request
seedlist = ['https://scrapy.org/']
def extract_urls(url):
"""
this function is used to extract URLs from HTML
"""
parser.add_argument('-v', '--verbose', action='count', default=0)
parser.add_argument('-q', '--quiet', action='count', default=0)
logging_level = logging.WARN + 10*args.quiet - 10*args.verbose
# script -vv -> DEBUG
# script -v -> INFO
# script -> WARNING
# script -q -> ERROR
# script -qq -> CRITICAL
def numeric_encoding(some_string):
mappings = {"A": "1", "G": "2", "C": "3", "T": "4"}
results = ""
for current in some_string:
results += mappings[current]
return results
numeric_encoding("AGCTTCA")
@sidharthshah
sidharthshah / hello_google_docs.py
Last active April 14, 2018 11:21
Python-Google-Sheet-Example
# This is example from https://developers.google.com/sheets/api/quickstart/python
"""
Shows basic usage of the Sheets API. Prints values from a Google Spreadsheet.
"""
from __future__ import print_function
from apiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
@sidharthshah
sidharthshah / Notes.md
Last active September 3, 2017 07:27
Notes from DeepLearning.TV's Youtube Videso
  • GEOFF HILTON {Father of DNN}
  • MLP {Multi Layered Perceptron} -> Vanialla Neural Network
  • Problem of Vanishing Gradient {This is what RBM Solves}

Unsupervised

RBM {Extract features and reconstruct inputs}

  • Forward/Backward Phase
# Grammar Based Natural Language Query Parser
# Background: I've implemented a better search engine for an eCommerce Site. There was a legacy code which had lot of
# if-else blocks. By using Grammer based parsing code I was able to reduce Line of Codes for Module and
# make it more extensible and maintainable
# Ref:
# 1. http://infohost.nmt.edu/tcc/help/pubs/pyparsing/pyparsing.pdf
# 2. http://q3k.org/gentoomen/Programming/Python/Getting%20Started%20with%20Pyparsing%20(2007).pdf
from pyparsing import Word, alphas, oneOf
@sidharthshah
sidharthshah / samples.py
Last active May 13, 2017 10:20
Sample Python Code
# This is Readable
>>> nums = []
>>> for i in range(1000):
... nums.append(random.randint(1, 1000))
...
# This is not readable
num_1 = [random.randint(1, 1000) for i in range(1000)]
# Traditional way of doing things
@sidharthshah
sidharthshah / science-wikipedia-articles.txt
Created October 14, 2015 03:35
List of wikipedia Pages relating to Science category
environmental change
resistor ladder
effects of high altitude on humans
mendelian inheritance
pellucidar
ryōji noyori
aphthous stomatitis
holonomic brain theory
umbilicus (mollusc)
destroy all humans!
@sidharthshah
sidharthshah / MinimalisticPomodoroTimer-V1.ino
Created October 31, 2013 15:27
Modified version from previous Sketch to consider changes for Initial Button State
//Vars relating to IO
int START_PIN = 10;
int DONE_PIN = 9;
int WIP_PIN = 8;
int BUZZER_PIN = 13;
int BUTTON_PIN = 2;
//Vars related to Button
int buttonState = HIGH;
int lastButtonState = HIGH;
@sidharthshah
sidharthshah / MinimalisticPomodoroTimer.ino
Created October 12, 2013 18:42
Minimalistic Timer for Pomodoro implemented on Arduino. Has very basic requirements of hardware 1. Piezo Buzzer 2. LED + Resistor set 3. Rest Button + 10K
//Vars relating to IO
int START_PIN = 10;
int DONE_PIN = 9;
int WIP_PIN = 8;
int BUZZER_PIN = 13;
int BUTTON_PIN = 2;
//Vars related to Button
int buttonState;
int lastButtonState = LOW;