Skip to content

Instantly share code, notes, and snippets.

View dilawar's full-sized avatar
🐕
w**king

Dilawar Singh dilawar

🐕
w**king
View GitHub Profile
@cobryan05
cobryan05 / webcamDetect.py
Last active April 22, 2024 11:40
Query registry for active webcam
# 2024-04-17: Stole changese from @Timmo on stackoverflow to get this working with Windows Apps
import winreg
class WebcamDetect:
REG_KEY = winreg.HKEY_CURRENT_USER
WEBCAM_REG_SUBKEY = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\CapabilityAccessManager\\ConsentStore\\webcam\\"
WEBCAM_TIMESTAMP_VALUE_NAME = "LastUsedTimeStop"
def __init__(self):
@awerlang
awerlang / README
Last active June 24, 2024 15:50
A zypper wrapper that maximizes network throughput
zypper-download
===============
Downloads packages using any amount of available openSUSE mirrors.
Installation
------------
Copy both files to the following locations:
@pirate
pirate / docker-compose-backup.sh
Last active January 26, 2025 23:38
Backup a docker-compose project, including all images, named and unnamed volumes, container filesystems, config, logs, and databases.
#!/usr/bin/env bash
### Bash Environment Setup
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
# set -o xtrace
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
@harish2704
harish2704 / zypper_dup_print_urls.py
Created October 1, 2018 18:17
parallel downloads while doing zypper distribution upgrade
#!/usr/bin/env python2
"""
This script will print package urls which need to be downloaded for 'distrubution upgrade'
Printed urls can be used for downloading packages in parallel.
For eg: we can use GNU parallel commanline tool along with wget/curl for parallel downloading
python2 zypper_dup_print_urls.py | parallel --tmuxpane -j4 --colsep ' ' mkdir -p '{1}/{2}' \; cd '{1}/{2}' \; wget -c {3}
will download packages with 4 simultaneous downloads
"""
@jsomers
jsomers / websockets.md
Created September 27, 2018 12:50
Using websockets to easily build GUIs for Python programs

Using websockets to easily build GUIs for Python programs

I recently built a small agent-based model using Python and wanted to visualize the model in action. But as much as Python is an ideal tool for scientific computation (numpy, scipy, matplotlib), it's not as good for dynamic visualization (pygame?).

You know what's a very mature and flexible tool for drawing graphics? The DOM! For simple graphics you can use HTML and CSS; for more complicated stuff you can use Canvas, SVG, or WebGL. There are countless frameworks, libraries, and tutorials to help you draw exactly what you need. In my case, this was the animation I wanted:

high-priority

(Each row represents a "worker" in my model, and each rectangle represents a "task.")

@CMCDragonkai
CMCDragonkai / nix_python_package.md
Last active December 16, 2024 15:23
An Illustration of a Nix Python Package #nix #python

An Illustration of a Nix Python Package

Every Python package (which is a collection of modules associated with version metadata) needs to have a setup.py.

So first create a relevant setup.py, refer to my article here: https://gist.github.com/CMCDragonkai/f0285cdc162758aaadb957c52f693819 for more information.

Remember that setup.py is meant to store version compatible ranges of

@igorepst
igorepst / install.sh
Created June 11, 2018 20:00
Install Vim8 with Python3 and GTK3 on CentOS 7.5
sudo yum install epel-release
sudo yum install gcc-c++ ncurses-devel ruby ruby-devel lua lua-devel luajit luajit-devel ctags python python-devel python3 python3-devel tcl-devel perl perl-devel perl-ExtUtils-ParseXS perl-ExtUtils-XSpp perl-ExtUtils-CBuilder perl-ExtUtils-Embed cscope gtk3-devel libSM-devel libXt-devel libXpm-devel libappstream-glib libacl-devel gpm-devel
yum list installed | grep -i vim
# sudo yum erase vim-common.x86_64 vim-enhanced.x86_64 vim-filesystem.x86_64 vim-X11
# sudo depends on vim-minimal
sudo rpm -e --nodeps vim-minimal
sudo ln -s /usr/bin/python3.6 python3
@tobiasraabe
tobiasraabe / python-downloader.py
Last active March 8, 2025 10:47
Script to download files, resume downloads and validate downloads. Everything wrapped with a beautiful progressbar.
import click
import hashlib
import requests
from pathlib import Path
from tqdm import tqdm
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
@davejm
davejm / latex-short-captions.lua
Created April 26, 2018 12:08 — forked from tarleb/latex-short-captions.lua
Filter to turn figure titles into short captions in LaTeX
-- don't do anything unless we target latex
if FORMAT ~= "latex" then
return {}
end
local List = require'pandoc.List'
local function latex(str)
return List:new{pandoc.RawInline('latex', str)}
end
@ygrenzinger
ygrenzinger / CleanArchitecture.md
Last active April 8, 2025 17:22
Summary of Clean Architecture by Robert C. Martin

Summary of book "Clean Architecture" by Robert C. Martin

Uncle Bob, the well known author of Clean Code, is coming back to us with a new book called Clean Architecture which wants to take a larger view on how to create software.

Even if Clean Code is one of the major book around OOP and code design (mainly by presenting the SOLID principles), I was not totally impressed by the book.

Clean Architecture leaves me with the same feeling, even if it's pushing the development world to do better, has some good stories and present robust principles to build software.

The book is build around 34 chapters organised in chapters.