This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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, |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
As answers to this Stack Overflow question
reveal, using <!---
and --->
or <!--
and -->
works (view source by clicking "Raw"):