Skip to content

Instantly share code, notes, and snippets.

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
c = plt.hist(np.random.rand(500), bins=30, color='yellow', edgecolor='black')
plt.figure()
x, y = sorted([round(i,2) for i in c[1][:-1]] ), sorted(c[0])
d = {}
for i in range(len(x)):
d[str(x[i])] = y[i]
plt.xticks([])
@srdg
srdg / wallgen.py
Last active January 30, 2020 05:31
from PIL import ImageDraw, Image
from random import randint, choices
from PIL.ImageColor import getrgb
from os import getcwd
from time import strftime
from string import ascii_letters
from pathlib import Path
Path(getcwd()+'/wallpapers').mkdir(parents=True, exist_ok=True)
def split_rectangle(draw,img):

Keybase proof

I hereby claim:

  • I am srdg on github.
  • I am soumik (https://keybase.io/soumik) on keybase.
  • I have a public key ASC5V03nvcThs2lkPUUZ72D75jpkN3zCH77o-hsyHMkxDAo

To claim this, I am signing this object:

@srdg
srdg / generator.py
Created September 21, 2018 07:51
Internship
import os
import shutil
import openpyxl
import datetime
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
#open Excel File
ob=openpyxl.load_workbook('demodata.xlsx')
#open Worksheet
import os
import shutil
import cv2
from PIL import Image
def rename_files():
# renames all files in folders recursively
try:
folders = sorted(os.listdir(os.getcwd()))
print(folders)
folder_idx=1
@srdg
srdg / Gsuite.py
Created August 8, 2018 13:40
Creating csv for Gsuite bulk upload and Mailchimp bulk notifications
from random import randint
import openpyxl
parent_str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
ob = openpyxl.load_workbook("College Mail Id for ECE (Responses).xlsx")
sh = ob["Form Responses 1"]
pwd_log = []
def create_password():
@srdg
srdg / mat2csv.py
Created March 23, 2018 10:18
Convert .mat files to .csv files instantly
import numpy as np
import scipy.io
data = scipy.io.loadmat("filename.mat") # Enter your filename here
for i in data:
if '__' not in i and 'readme' not in i:
fp = open(i+".csv","w+") # numpy.savetext does not create files automatically
np.savetxt((i+".csv"),data[i],delimiter=',')