Skip to content

Instantly share code, notes, and snippets.

View PandaWhoCodes's full-sized avatar

Thomas Ashish Cherian PandaWhoCodes

View GitHub Profile
@PandaWhoCodes
PandaWhoCodes / typing_letters_pgz.py
Created November 24, 2019 05:26
A pygame zero game to shoot falling letters
import pgzrun
from random import randint,choice
import string
letters = [] # will store letter,x,y
WIDTH = 800
HEIGHT = 500
velocity = 1
colors = [0, 0, 0]
@PandaWhoCodes
PandaWhoCodes / typing_letters.py
Created November 22, 2019 08:08
A pygame to shoot falling letters
import random
import string
import sys
import pygame
# Initializing pygame
pygame.init()
# setting font
myfont = pygame.font.SysFont('monospace', 50)
import imaplib
import email
import os
def create_folder(folder_name="backup"):
"""
Creates a folder to store all mails
"""
if not os.path.exists(folder_name):
from bs4 import BeautifulSoup
from glob import glob
import os
import json
def get_folders(path=os.getcwd()):
"""
return a lst of all sub directories inside a folder
:param path: string
corr = housing.corr()
# Using mask to get triangular correlation matrix
f, ax = plt.subplots(figsize=(15, 15))
mask = np.zeros_like(corr, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True
sns.heatmap(corr, mask=mask, cmap=sns.diverging_palette(220, 10, as_cmap=True), square=True, ax=ax, vmin = -1.0, vmax = 1.0, linewidths=.5)
@PandaWhoCodes
PandaWhoCodes / dijkstra.py
Created October 26, 2019 14:13 — forked from zaz/dijkstra.py
Dijkstra's algorithm — Python
# Zaz Brown
# github.com/zaz/dijkstra
"""An efficient algorithm to find shortest paths between nodes in a graph."""
from collections import defaultdict
class Digraph(object):
def __init__(self, nodes=[]):
self.nodes = set()
self.neighbours = defaultdict(set)
self.dist = {}
@PandaWhoCodes
PandaWhoCodes / get_all_links.py
Last active June 5, 2023 15:36
Code to retrieve all links from a given URL
def get_nth_fibo(n,cache):
if n in cache:
return cache[n]
else:
cache[n] = get_nth_fibo(n-1,cache) + get_nth_fibo(n-2,cache)
return cache[n]
print(get_nth_fibo(1,{1:0,2:1}))
def get_nth_fibo(n):
if n == 0:
return 0
elif n ==2:
return 1 # the second number in the fibonacci series is always 1
elif n == 1:
return 0 # the first number in the fibonacci series is always 1
else:
return get_nth_fibo(n-1) + get_nth_fibo(n-2)
@PandaWhoCodes
PandaWhoCodes / sol1.py
Created August 17, 2019 02:44
Solution for code challenge - all solutions - http://ashish.ch/solution-find-the-non-duplicate-number/
# Solution by Sai Ganesh
def singleNumber(nums):
dnum = {}
for i in nums:
if i in dnum.keys():
dnum[i]+=1
if i not in dnum.keys():
dnum[i] = 1
for k in dnum:
if dnum[k] == 1: