Skip to content

Instantly share code, notes, and snippets.

View vaishaks's full-sized avatar

Vaishak Salin vaishaks

View GitHub Profile
@vaishaks
vaishaks / cloudSettings
Last active February 20, 2020 01:28
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-02-20T01:25:45.272Z","extensionVersion":"v3.4.3"}
csvstring = ''
for i in xrange(start, stop+1):
cols = rows[i].find_all('td')
for col in cols:
try:
csvstring = csvstring + col.contents[0] + ','
except IndexError:
pass
csvstring = csvstring + '\n'
print csvstring
rows = tables[0].find_all('tr') # Extract all rows from the first table
start = 0
stop = 0
# Find the starting point
for row in rows:
if 'STATES' in str(row):
break
start += 1
start += 1
stop = start
htmldata = ''
with open(filename+'.html', 'r') as htmlfile:
htmldata = htmldata + htmlfile.read()
soup = BeautifulSoup(htmldata, 'html.parser')
import requests
import pandas as pd
import numpy as np
from bs4 import BeautifulSoup
htmlfile = open(filename+'.html', 'w+')
files = {'f': (filename+'.pdf', open(filename+'.pdf', 'rb'))}
response = requests.post("https://pdftables.com/api?key=r4i5cvh74tvn", files=files)
response.raise_for_status() # ensure we notice bad responses
for chunk in response.iter_content(chunk_size=1024):
@vaishaks
vaishaks / HashTable.cpp
Created July 29, 2014 18:11
Using a hashtable in C++
#include "stdafx.h"
#include <iostream>
#include <string>
#include <unordered_map>
#include <conio.h>
using namespace std;
int main()
{
unordered_map<string, string> hashTable;
@vaishaks
vaishaks / deep-reverse.scm
Last active December 29, 2015 05:48
It's rolling in the deeeep-reverse!
(define L '((1 2) 3 (4 (5 6))))
(define deep-reverse
(lambda (L)
(if (null? L)
'()
(if (list? (car L))
(append (deep-reverse (cdr L)) (list (deep-reverse (car L))))
(append (deep-reverse (cdr L)) (list (car L)))))))
(newline)
@vaishaks
vaishaks / learn-scheme.scm
Created November 23, 2013 11:19
Scheme basics.
(+ 3 (* 4 5)) ;A basic scheme expression
(define a 1) ;Defining a value
(define b 1)
(and (= a b) (not (= a 0))) ;A logical expression
(display "Enter a number: ") ;Output
(define x (read)) ;Input
(display "The square of that number is ")
@vaishaks
vaishaks / quicksort.scm
Created November 22, 2013 19:47
Quicksort in scheme. It's beautiful! :'(
(define less
(lambda (L x)
(cond ((null? L) '())
((< (car L) x) (cons (car L) (less (cdr L) x)))
(else (less (cdr L) x)))))
(define great
(lambda (L x)
(cond ((null? L) '())
((> (car L) x) (cons (car L) (great (cdr L) x)))
def dfs(graph, node):
"""Run DFS through the graph from the starting
node and return the nodes in order of finishing time.
"""
stack = [[node, True]]
while True in [x[1] for x in stack]:
i = 0
for x in xrange(len(stack)):
if stack[x][1] == True:
i = x