Skip to content

Instantly share code, notes, and snippets.

View shreyansh26's full-sized avatar
👨‍🎓
Always Learning

Shreyansh Singh shreyansh26

👨‍🎓
Always Learning
View GitHub Profile
@shreyansh26
shreyansh26 / downloadXkcd.py
Created June 13, 2017 20:19
A WebScraper in python to download all Xkcd comics
#! python3
# downloadXkcd.py - Downloads every single XKCD comic.
import requests, os, bs4
url = 'http://xkcd.com' # starting url
os.makedirs('xkcd', exist_ok=True) # store comics in ./xkcd
while not url.endswith('#'):
# Download the page.
print('Downloading page %s...' % url)
@shreyansh26
shreyansh26 / quicksort.sh
Created July 6, 2017 08:00
Quicksort in shell script
#!/bin/bash
function partition {
let i=$2-1
let pivot=${x[$3]}
for(( j="$2"; j<"$3"; j++ ))
do
if [ "${x[$j]}" -lt "$pivot" ]
then
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
int a[n];
bool b[n];
fill(b, b + n, true);
https://www.analyticsvidhya.com/blog/2017/07/web-scraping-in-python-using-scrapy/
https://www.analyticsvidhya.com/blog/2017/07/beginner-guide-build-data-visualisations-web-d3-js/
https://www.analyticsvidhya.com/blog/2017/07/30-questions-test-data-scientist-natural-language-processing-solution-skilltest-nlp/
https://www.analyticsvidhya.com/blog/2017/07/word-representations-text-classification-using-fasttext-nlp-facebook/
# Implementation of classic arcade game Pong
try:
import simplegui
except ImportError:
import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
import random
# initialize globals - pos and vel encode vertical info for paddles
import numpy as np
from numba import jit
@jit
def aprox_pi(N):
points = 2 * np.random.rand(N, 2) - 1
M = 0
for k in range(N):
if points[k,0]**2 + points[k,1]**2 < 1.:
f = open('tempSum2', 'r')
sum = 0
for l in f:
if not l.strip():
continue
sum += int(l.strip())
print(sum)
f = open('sumFile2', 'r')
f2 = open('tempSum2', 'w')
import re
for line in f:
line2 = re.sub(r'\s' , '\n', line)
f2.write(line2)
f.close()
f2.close()
f = open('file-20171020T1500.json', 'r')
import json
import operator
dc = {}
dc_n = {}
for l in f:
j = json.loads(l)
scans = j["scans"]
import os
import glob
import hashlib
a = set()
filenames = glob.glob("./waldo/*.jpg")
for filename in filenames:
with open(filename, 'rb') as inputfile:
data = inputfile.read()