Skip to content

Instantly share code, notes, and snippets.

View mostaphaRoudsari's full-sized avatar

Mostapha Sadeghipour Roudsari mostaphaRoudsari

View GitHub Profile
@okld
okld / multipage_settings_app.py
Last active September 25, 2023 13:50
Streamlit - Settings page with session state
import streamlit as st
from persist import persist, load_widget_state
def main():
if "page" not in st.session_state:
# Initialize session state.
st.session_state.update({
# Default page.
"page": "home",
import os
import signal
import subprocess
import sys
# Parse command-line arguments.
if len(sys.argv) > 1:
folder = os.path.abspath(sys.argv[1])
else:
folder = os.path.abspath(os.getcwd())
@alferov
alferov / docker-rm-images.md
Last active July 24, 2023 08:33
Remove all (untagged) images and containers from Docker
# Delete all containers
docker rm $(docker ps -aq)
# Delete all images
docker rmi $(docker images -q)
# Delete all untagged images
docker rmi $(docker images -q --filter "dangling=true")

References:

@piac
piac / list_to_tree.py
Last active October 31, 2022 20:01
Transforms DataTrees in Grasshopper to nestings of lists, and vice versa
def list_to_tree(input, none_and_holes=True, source=[0]):
"""Transforms nestings of lists or tuples to a Grasshopper DataTree"""
from Grasshopper import DataTree as Tree
from Grasshopper.Kernel.Data import GH_Path as Path
from System import Array
def proc(input,tree,track):
path = Path(Array[int](track))
if len(input) == 0 and none_and_holes: tree.EnsurePath(path); return
for i,item in enumerate(input):
if hasattr(item, '__iter__'): #if list or tuple
@jkschneider
jkschneider / README.md
Last active July 14, 2019 19:34
Dependency Tree

About

This is a simple demonstration of the use of a constraint-based force layout to represent the dependency hierarchy. Subgraphs are not repeated as they are in the console rendering. As a result, we don't have to make any special provision for dependency cycles.

The Floyd-Warshall algorithm is used to display relative path distances. Floyd-Warshall has been extended with path reconstruction as well to show the shortest path solutions between nodes.

It is possible the display could be improved further through hierarchical grouping to highlight the commonly repeated subgraphs (e.g. the subgraph including the path L->I->O->P->Q).

How to use

@chandlerprall
chandlerprall / threaded_download.py
Created June 9, 2011 17:41
Small Python multi-threaded file downloader
import urllib2
import threading
from Queue import Queue
import sys, os, re
class ThreadedDownload(object):
REGEX = {
'hostname_strip':re.compile('.*\..*?/', re.I)
}