Skip to content

Instantly share code, notes, and snippets.

View Parassharmaa's full-sized avatar
🎯
Focusing

Paras Sharma Parassharmaa

🎯
Focusing
View GitHub Profile
@Parassharmaa
Parassharmaa / conf
Created December 16, 2017 09:12
Configuration for reverse proxy nginx
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name <domain_name>.com www.<domain_name>.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
@Parassharmaa
Parassharmaa / Output.txt
Last active September 7, 2017 16:39
Loops vs. Recursion
Testing for 100 items
-----
Time Take by loop: 8.668698137626052e-05
Time Take by recursion: 0.00011143798474222422
Testing for 100 items
-----
Time Take by loop: 8.37119878269732e-05
Time Take by recursion: 0.00011085800360888243
Testing for 10000 items
-----
@Parassharmaa
Parassharmaa / algorithms.py
Created September 6, 2017 17:41
Experiments with algorithms (Divide and conquer, Knapsack)
import timeit
from random import randint
def selection_sort(l):
for i in range(len(l)):
j = i
for k in range(i+1, len(l)):
if l[k] < l[j]:
j = k
l[i], l[j] = l[j], l[i]
@Parassharmaa
Parassharmaa / Dockerfile
Last active August 15, 2017 15:29
Docker : Python Flask Deployment
FROM python:3.4
RUN pip install Flask==0.10.1 uWSGI==2.0.8
WORKDIR /app
COPY app /app
CMD ["uwsgi", "--http", "0.0.0.0:9090", "--wsgi-file", "/app/server.py", \
"--callable", "app", "--stats", "0.0.0.0:9191"]
@Parassharmaa
Parassharmaa / image-processing-numpy.ipynb
Created July 11, 2017 09:47
Image Processing in numpy
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Parassharmaa
Parassharmaa / callback.js
Created July 2, 2017 11:42
Asynchronous nature of javascript
const https = require("https")
// https request to api server
https.get("https://api.github.com/users/parassharmaa", (response) => {
//callback function which is asynchronous and non-blocking
console.log(response.statusCode);
})
@Parassharmaa
Parassharmaa / promise_example.js
Last active July 2, 2017 11:49
Promise in node
const https = require('https');
let user = (name) => {
const url = `https://www.instagram.com/${name}/?__a=1`;
//return promise
return new Promise((resolve, reject) => {
const request = https.get(url, response => {
if (response.statusCode < 200 || response.statusCode > 299) {
//reject promise on error
reject(new Error('Failed to load page, status code: ' + response.statusCode));
@Parassharmaa
Parassharmaa / tw_thread_image.py
Last active August 5, 2021 23:10
Python script to download image from a tweet thread.
from bs4 import BeautifulSoup
import requests
import urllib.request
data = requests.get("https://twitter.com/AmeyShrivastav1/status/857315283253559296").text
soup = BeautifulSoup(data, "html.parser")
#array of tags
img_data = soup.find_all("div", {"class": "AdaptiveMedia-photoContainer"})
@Parassharmaa
Parassharmaa / lastEdit.js
Created June 8, 2017 07:03
List last edit time of file in a directory (using promises and moment.js)
let Promise = require("bluebird");
let fs = Promise.promisifyAll(require("fs"));
let moment = require('moment')
let getFiles = directory => {
return fs.readdirAsync(directory)
}
let getStat = filename => {
@Parassharmaa
Parassharmaa / bfs.py
Created March 15, 2017 13:51
Breadth First Search : : Graph - Python
import collections
class SimpleGraph:
def __init__(self):
self.edges = {}
def neighbors(self, id):
return self.edges[id]