Skip to content

Instantly share code, notes, and snippets.

View mjbear's full-sized avatar
💻

Michael Bear mjbear

💻
View GitHub Profile
@jczaplew
jczaplew / tqdm-multithreading.py
Last active March 20, 2025 23:03
tqdm with multithreading
from tqdm import *
from queue import Queue
from threading import Thread
import time
THREADS = 4
class WorkerThread(Thread):
def __init__(self, queue):
Thread.__init__(self)
@hellt
hellt / vifmove.sh
Last active November 10, 2024 13:06
Virsh interface move
#!/bin/bash
# usage ~/vifmove.sh <virsh_domain_name/id> <interface_name> <new_bridge_name>
tmpxml=$(mktemp /tmp/ifcfg.XXX)
macaddr="$(virsh domiflist $1 | awk "/$2\s/ {print \$NF}")"
cat > "$tmpxml" <<EOF
<interface type='bridge'>
<mac address='$macaddr'/>
<source bridge='$3'/>
<model type='virtio'/>
</interface>
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active April 24, 2025 07:18
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@dingzeyuli
dingzeyuli / check_github_repo_size
Created December 16, 2016 22:34
Check the size of a github repo before downloading
# http://webapps.stackexchange.com/questions/39587/view-estimated-size-of-github-repository-before-cloning
# tested on macOS
echo https://github.com/torvalds/linux.git | perl -ne 'print $1 if m!([^/]+/[^/]+?)(?:\.git)?$!' | xargs -I{} curl -s -k https://api.github.com/repos/'{}' | grep size
# output:
# "size": 1746294,
@amitsaha
amitsaha / overlayfs.md
Last active September 27, 2024 15:54
overlayfs on Fedora 24

OverlayFS on Fedora 24

Create a lower directory and upper directory

$ tree upper/ lower/
upper/
├── upper-file1
└── upper-subdir1
lower/
@tasdikrahman
tasdikrahman / python_tests_dir_structure.md
Last active February 10, 2025 22:15
Typical Directory structure for python tests

A Typical directory structure for running tests using unittest

Ref : stackoverflow

The best solution in my opinion is to use the unittest [command line interface][1] which will add the directory to the sys.path so you don't have to (done in the TestLoader class).

For example for a directory structure like this:

new_project

├── antigravity.py

@uupaa
uupaa / image.resize.in.github.flavored.markdown.md
Last active April 22, 2025 11:44
image resize in github flavored markdown.

Image source

https://gyazo.com/eb5c5741b6a9a16c692170a41a49c858.png

Try resize it!

  • ![](https://gyazo.com/eb5c5741b6a9a16c692170a41a49c858.png | width=100)
@ozh
ozh / git cherry-pick within a pull request.md
Last active January 6, 2025 03:16
git cherry-pick within a pull request

1. Create new branch:

git checkout -b otherrepo-master master

2. Get the contents of the PR

git pull https://github.com/otherrepo/my-repo-name.git master
@JungeAlexander
JungeAlexander / import-package-from parent.py
Created November 27, 2014 17:22
Import modules from parent folder in Python
# From http://stackoverflow.com/a/11158224
# Solution A - If the script importing the module is in a package
from .. import mymodule
# Solution B - If the script importing the module is not in a package
import os,sys,inspect
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parent_dir = os.path.dirname(current_dir)
sys.path.insert(0, parent_dir)
@jonikarppinen
jonikarppinen / markdown-comments.md
Last active April 10, 2025 20:16
How to comment out stuff in Markdown on GitHub?

Comments in GitHub flavour of Markdown

As answers to this Stack Overflow question reveal, using <!--- and ---> or <!-- and --> works (view source by clicking "Raw"):