Skip to content

Instantly share code, notes, and snippets.

View chienhsiang-hung's full-sized avatar

洪健翔 Hung, Chien-Hsiang chienhsiang-hung

View GitHub Profile
@chienhsiang-hung
chienhsiang-hung / tuple and list, and str concat.ipynb
Created March 9, 2023 04:33
iterate through list and tuple / How To Efficiently Concatenate Strings In Python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chienhsiang-hung
chienhsiang-hung / heapq.ipynb
Created November 14, 2022 09:29
Heap data structure is mainly used to represent a priority queue. In Python, it is available using the “heapq” module. The property of this data structure in Python is that each time the smallest heap element is popped(min-heap).
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chienhsiang-hung
chienhsiang-hung / Simple Topological Sorting (DAG).py
Created November 7, 2022 10:01
Simple Topological Sorting (DAG).py
from collections import defaultdict
class Graph:
def __init__(self, vertices):
'''
@vertices: number of vertices
'''
self.graph = defaultdict(list) # adjacency list
self.V = vertices
import logging
import requests
from requests.adapters import HTTPAdapter, Retry
logging.basicConfig(level=logging.DEBUG)
session = requests.Session()
retries = Retry(total=5, backoff_factor=1, status_forcelist=[502, 503, 504])
session.mount('http://', HTTPAdapter(max_retries=retries))