Skip to content

Instantly share code, notes, and snippets.

View shdwkl's full-sized avatar

shdwkl

  • 我的鸡巴
View GitHub Profile
@shdwkl
shdwkl / lru.py
Last active May 20, 2023 21:56
Least Recently Used Implementation
from threading import RLock
from collections import namedtuple
_CacheInfo = namedtuple("CacheInfo", ["hits", "misses", "maxsize", "currsize"])
################################################################################
### update_wrapper() and wraps() decorator
################################################################################
@shdwkl
shdwkl / multi-repo.py
Last active January 12, 2023 22:35
script to download all repos opened in web browser just export all tabs and an it will do the rest of work
import os
from itertools import chain
from pathlib import Path
from bs4 import BeautifulSoup
from git import RemoteProgress
from git.repo.base import Repo
from tqdm import tqdm
BASE_DIR = Path(__file__).resolve().parent
@shdwkl
shdwkl / SETUP_DAY.md
Created November 2, 2022 00:18
Starting my coding journey...
@shdwkl
shdwkl / status.py
Created October 28, 2022 04:07
Descriptive HTTP status codes, for code readability.
"""
Descriptive HTTP status codes, for code readability.
See RFC 2616 - https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
And RFC 6585 - https://tools.ietf.org/html/rfc6585
And RFC 4918 - https://tools.ietf.org/html/rfc4918
"""
def is_informational(code):
@shdwkl
shdwkl / eulerian_path_and_circuit_for_undirected_graph.py
Created June 22, 2022 08:26
Eulerian Path is a path in graph that visits every edge exactly once. || Eulerian Circuit is an Eulerian Path which starts and ends on the same || vertex. || time complexity is O(V+E) || space complexity is O(VE)
# Eulerian Path is a path in graph that visits every edge exactly once.
# Eulerian Circuit is an Eulerian Path which starts and ends on the same
# vertex.
# time complexity is O(V+E)
# space complexity is O(VE)
# using dfs for finding eulerian path traversal
def dfs(u, graph, visited_edge, path=None):
path = (path or []) + [u]
@shdwkl
shdwkl / translate_into_arabic.py
Created January 21, 2022 17:47
Translator From any Language into arabic
#!/usr/bin/env python3
import logging
from pathlib import Path
from string import Template
import click
from googletrans import Translator
@shdwkl
shdwkl / .p10k.zsh
Created January 7, 2022 16:19
powerlevel10k config file
# p10k.zsh configuration file
#
# Author: Thomas Bendler <[email protected]>
# Date: Sun Jan 12 17:54:00 CET 2020
#
# Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 551.
# For more information see https://github.com/romkatv/powerlevel10k
#
# Apply configiguration changes without restarting zsh.
# Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`.
@shdwkl
shdwkl / threading.py
Created November 6, 2021 14:10
Threading is a technique for decoupling tasks which are not sequentially dependent. Threads can be used to improve the responsiveness of applications that accept user input while other tasks run in the background. A related use case is running I/O in parallel with computations in another thread. The following code shows how the high level thread…
import threading, zipfile
class AsyncZip(threading.Thread):
def __init__(self, infile, outfile):
threading.Thread.__init__(self)
self.infile = infile
self.outfile = outfile
def run(self):
{
"theme": "serika_dark",
"customTheme": false,
"customThemeColors": [
"#323437",
"#e2b714",
"#e2b714",
"#646669",
"#d1d0c5",
"#ca4754",
@shdwkl
shdwkl / collatz-conj.py
Created September 11, 2021 16:14
Find the number of steps it takes to reach one using the Collatz conjecture
'''
author: yusufadell
Name: collatz-conj.py
Purpose: Find the number of steps it takes to reach one using the following process:
If n is even, divide it by 2. If n is odd, multiply it by 3 and add 1.
Author: Yusuf Adel (y8l)
Algorithm: Collatz conjecture
License: MIT