Skip to content

Instantly share code, notes, and snippets.

View rishi-raj-jain's full-sized avatar
☺️

Rishi Raj Jain rishi-raj-jain

☺️
View GitHub Profile
server {
listen 80;
listen [::]:80;
root /usr/share/nginx/html;
index index.html;
location / {
import sys
import networkx as nx
import matplotlib.pyplot as plt
import community as community_louvain
from community import generate_dendrogram, best_partition, partition_at_level
from pymongo import MongoClient
import matplotlib.cm as cm
import pprint, json
import matplotlib.colors as colors
import matplotlib.cm as cmx
import sys, csv, pprint, json
import networkx as nx
import matplotlib.pyplot as plt
import community as community_louvain
import matplotlib.cm as cm
from community import generate_dendrogram, best_partition, partition_at_level
from pymongo import MongoClient
from networkx.readwrite import json_graph
import threading
import sys, csv, pprint, json
import networkx as nx
import matplotlib.pyplot as plt
import community as community_louvain
import matplotlib.cm as cm
from community import generate_dendrogram, best_partition, partition_at_level
from pymongo import MongoClient
from networkx.readwrite import json_graph
# Connecting to the db
@rishi-raj-jain
rishi-raj-jain / get-unsplash-photos-from-user-handle.js
Created March 6, 2021 09:47
get-unsplash-photos-from-user-handle
import got from "got/dist/source";
import { JSDOM } from "jsdom";
export default async (req, res) => {
let images = [];
const response = await got(`https://unsplash.com/@${req.query.userHandle}`);
if (response.statusCode === 200) {
const dom = new JSDOM(response.body);
let allA = dom.window.document.querySelectorAll(
'[itemProp="contentUrl"] img'
@rishi-raj-jain
rishi-raj-jain / plot-grayscale-wordclouds.py
Created March 25, 2021 17:26
Plot grayscale wordclouds with ease.
# Import pymongo, pandas and matplotlib
import tqdm, re, pandas as pd, random
import matplotlib.pyplot as plt
# Import wordcloud library
from wordcloud import WordCloud, STOPWORDS
stopwords= set(STOPWORDS)
# Define the colors for grayscale
def grey_color_func(word, font_size, position, orientation, random_state=None, **kwargs):
@rishi-raj-jain
rishi-raj-jain / get-compiled-english-devanagari-package-overleaf-text.py
Last active October 5, 2021 13:26
Easier than ever to include hindi text in pdflatex-only files
# Process.py
# The repaired version of https://gist.github.com/shreevatsa/4d476ac26a367fa68984d8c06867d7dd#file-get-dn-py
from __future__ import unicode_literals
import os
import re
import subprocess
import sys
// This file was added by layer0 init.
// You should commit this file to source control.
const { Router } = require("@layer0/core/router")
const { nuxtRoutes } = require("@layer0/nuxt")
module.exports = new Router()
.match("/service-worker.js", ({ serviceWorker }) => {
serviceWorker(".nuxt/dist/client/service-worker.js");
})
@rishi-raj-jain
rishi-raj-jain / routes.js
Last active June 24, 2021 11:39
HSTS (Strict-Transport-Security) Headers
const { Router } = require('@layer0/core/router')
new Router()
.get("/:route", ({ setResponseHeader }) => {
setResponseHeader("Strict-Transport-Security", "max-age=31536000; includeSubDomains")
}
)
@rishi-raj-jain
rishi-raj-jain / routes.js
Last active June 29, 2021 10:59
(COOP) Cross-Origin Opener Policy Headers
const { Router } = require('@layer0/core/router')
new Router()
.get("/:route", ({ setResponseHeader }) => {
setResponseHeader("Cross-Origin-Opener-Policy", "same-origin-allow-popups")
}
)