Skip to content

Instantly share code, notes, and snippets.

View gethand.py
import requests
payload = {"text": "Mytext", "style": 0, "bias": 0.1}
url = "https://handwriting-generator.herokuapp.com/write"
page = requests.post(url, json=payload)
with open("x.png", "wb") as fl:
fl.write(page.content)
View getters.py
def get_flag():
con = None
flag = None
while True:
try:
con = swat.CAS() if con is None else con
flag = con.CASTable() if flag is None else flag
except Exception:
con = flag = None
else:
View covid19.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View flatten.py
d = {
"a1": {
"b1": {
"c1": {4, 5},
"c2": "123",
"c3": tuple(),
"c4": 100_000,
"c5": 1 ** 200000,
},
"b2": "something else",
View dchatterjee.nginx
upstream api_servers {
localhost:8080;
localhost:8081;
}
server {
server_name www.deb.com;
root /www;
location / {
View FiboMod.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View sc.py
from torch import nn
from torch import optim
from tqdm import tqdm
from tensorboardX import SummaryWriter
import torch
n = 100
inp = torch.Tensor([[0, 0],
[0, 1],
@theSage21
theSage21 / arxivnoredirect.js
Created Dec 6, 2018
Don't redirect a pdf link to a abstract link if there's a noredirect=1 parameter
View arxivnoredirect.js
// ==UserScript==
// @name ArxivPdfNoRedirect
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://arxiv.org/abs/*
// @grant none
// @require https://code.jquery.com/jquery-3.2.1.min.js
View rnmhdn.py
import numpy as np
from tqdm import tqdm
from multiprocessing import Pool
file_name = "test.gro" #Should be changed
frame_count = 14 #Should be changed
line_count = 4014 #Should be changed
Lz = 2.84 #Should be changed
Lx = 6.95
@theSage21
theSage21 / demo.py
Last active Oct 12, 2018
Tqdm + pool.imap_unordered
View demo.py
from tqdm import tqdm
from multiprocessing import Pool
def myfn(x):
return x ** 2
with Pool() as pool:
args = list(range(1_000_000))
work = pool.imap_unordered(myfn, args, chunksize=100)