Skip to content

Instantly share code, notes, and snippets.

View djinn's full-sized avatar

Supreet Sethi djinn

View GitHub Profile
@djinn
djinn / map_relation.py
Created December 19, 2019 01:30
Graph edge lookup specifically implemented for relation lookup on phone numbers
from json import loads
from random import choice, randint, sample
import timeit
# With this model it is imperative to use integer form of phone number instead of string
# We will use median contact frequency distribution from customer data
# Maximum contacts: 14551
# Minmum: 233
@djinn
djinn / image-proxy.conf
Created November 21, 2019 02:27 — forked from tmaiaroto/image-proxy.conf
Nginx Image Filter Resize Proxy Service
# Feel free to change this path of course (and keys_zone value as well, but also change the usage of it below).
proxy_cache_path /var/www/cache/resized levels=1:2 keys_zone=resizedimages:10m max_size=1G;
# Gzip was on in another conf file of mine...You may need to uncomment the next line.
#gzip on;
gzip_disable msie6;
gzip_static on;
gzip_comp_level 4;
gzip_proxied any;
# Again, be careful that you aren't overwriting some other setting from another config's http {} section.
#!/usr/bin/env python3
# Supreet Sethi <[email protected]>
# Date: 21-05-2019
from subprocess import check_output
from collections import defaultdict, Counter
from requests import get
from bs4 import BeautifulSoup as Soup
from urllib.parse import urljoin, urlparse
#do whois
@djinn
djinn / django_deploy.md
Last active May 2, 2019 13:39 — forked from bradtraversy/django_deploy.md
Django Deployment - Digital Ocean

Django Deployment to Ubuntu 18.04

In this guide I will go through all the steps to create a VPS, secure it and deploy a Django application. This is a summarized document from this digital ocean doc

Any commands with "$" at the beginning run on your local machine and any "#" run when logged into the server

Create A Digital Ocean Droplet

Use this link and get $10 free. Just select the $5 plan unless this a production app.

@djinn
djinn / anagram_prime.py
Created May 2, 2019 04:06
Fast algorithm to find anagram of a word using preindex of words
#!/usr/bin/env python3
# Author: Supreet Sethi <[email protected]>
# License: Creative Commons BY-SA 2.0
from string import ascii_lowercase
WORDSFILE = '/usr/share/dict/words' # this is specific to mac os
def alphabet_prime_data():
@djinn
djinn / smartkarma_rss_feed.txt
Created February 9, 2019 17:51
List of RSS feeds from Smartkarma
https://www.smartkarma.com/segment/feeds/issfocus.rss
https://www.smartkarma.com/segment/feeds/reports.rss
https://www.smartkarma.com/segment/feeds/cons.rss
https://www.smartkarma.com/segment/feeds/growth.rss
https://www.smartkarma.com/segment/feeds/multi_strategy.rss
https://www.smartkarma.com/segment/feeds/[email protected]
https://www.smartkarma.com/segment/feeds/china.rss
https://www.smartkarma.com/segment/feeds/equity_bottom_up.rss
https://www.smartkarma.com/segment/feeds/thematic_&_strategy.rss
https://www.smartkarma.com/segment/feeds/tmt.rss
@djinn
djinn / flatten.py
Created July 25, 2016 17:01
Flatten list without using stdlib function
import unittest
def flatten(l):
collect = []
# make user l is iterable of some sort and not a dictionary
if hasattr(l, '__iter__') and not isinstance(l, dict):
for e in l:
print e
print flatten(e)
collect += flatten(e)
@djinn
djinn / ifsc.py
Created July 15, 2016 07:12
Download entire Indian Banks IFSC code database as xls files
#!/usr/bin/env python
#pip install requests
#pip install bs4
#Author: Supreet Sethi <[email protected]>
#Date: Fri Jul 15 14:11:38 WIB 2016
#License: MIT
from requests import get
import cookielib
from bs4 import BeautifulSoup
@djinn
djinn / Shopify.Oauth.ex
Last active January 21, 2017 21:00
Shopify Oauth strategy for Elixir
defmodule Shopify.Oauth do
@moduledoc """
An OAuth2 strategy for Shopify.
Based on the OAuth2 strategy for GitHub by Sonny Scroggin
in https://github.com/scrogson/oauth2_example
"""
use OAuth2.Strategy
alias OAuth2.Strategy.AuthCode
alias OAuth2.Request
@djinn
djinn / reward.py
Created August 27, 2014 05:56
Sample code of reward process written in Python
rom collections import namedtuple
product = namedtuple("Product", [
'catalog_id',
'price',
'basic_discount',
'user_specific_discount',
'category'])