“Never memorize something that you can look up.”
#Einstein
by flandersen
Posted on July 11, 2020
autopep8 automatically formats Python code to conform to the PEP 8 style guide. It uses the pycodestyle utility to determine what parts of the code needs to be formatted. autopep8 is capable of fixing most of the formatting issues that can be reported by pycodestyle. – https://pypi.org/project/autopep8/
Open your project folder in VScode.
Install autopep8
onto your system or virtualenv.
pip install autopep8
Now, add the following lines to .vscode/settings.json
:
{
"python.pythonPath": "d:\\PyTestProj\\.venv\\Scripts\\python.exe",
"python.linting.pep8Enabled": true,
"python.formatting.provider": "autopep8"
}
Important: Add a comma at the end of the first conifg.
In VScode, press CTRL+Shift+P
which will then show you a list of commands. “autopep8” should be the first item. Acknowledge selection with the ENTER.
by flandersen
Posted on May 02, 2020
Open a console to the ESXi host.
vmkfstools --server -E "[MyStorage] MyVM/Disk_2.vmdk" "[SCADA] MyVM/Data.vmdk"
The disk name must be changed in the respective *.vmx file of the VM, like e.g. MyVM.vmx.
Read Moreby flandersen
Posted on April 29, 2020
In Windows 10, it is not easy to find the dialog where you can configure the sound devices, e.g.:
For making things easier, you can put a batch file in reach executing:
"C:\WINDOWS\system32\rundll32.exe" shell32.dll,Control_RunDLL mmsys.cpl,,recording
by flandersen
Posted on February 23, 2019
I use Jekyll to create my webpage.
# Install the dependencies specified in your Gemfile
bundle install
# Respectively update dependencies with
bundle update
# build jekyll page
bundle exec jekyll build
# serve jekyll page (host address overrides url in _config.yml)
bundle exec jekyll serve --host 192.168.1.30 --port 8080
For more info about Jekyll, see https://jekyllrb.com/
Read Moreby flandersen
Posted on February 23, 2019
Virtual environments in Python are used to decouple the dependencies of multiple python projects by putting them into a project sub-directory. It is not to be confused with Virtual Machines, which can isolate code execution from the host system, but in contrast require a separate operating system and a lot more system resources.
# goto project directory
cd my_project
# create virtual environment
$ python -m venv .venv
# activate the virtual environment (linux)
source .venv/bin/activate
# activate the virtual environment (windows powershell)
.venv/Scripts/Activate.ps1
# create a file named requirements.txt
echo "requests==2.18.3" >> requirements.txt
echo "beautifulsoup4==4.6.0" >> requirements.txt
echo "isoweek==1.3.3" >> requirements.txt
pip install -r requirements.txt
The dependencies can now be found in the sub-folder .venv
.
For further informations about using virtual environments in Python:
https://packaging.python.org/guides/installing-using-pip-and-virtualenv/
by flandersen
Posted on February 23, 2019
Merging a Git branch locally can be done the following.
Source: changing_index_page
Target: master
# listing branches (* = current branch)
$ git branch
* changing_index_page
master
# checkout target branch
$ git checkout master
$ git merge changing_index_page
59 files changed, 181 insertions(+), 809 deletions(-)
# delete branch
$ git branch -d changing_index_page
Deleted branch changing_index_page (was 11c2e2d).
Atlassian has a nice Git tutorial: https://www.atlassian.com/git
Read Moreby flandersen
Posted on February 23, 2019
Copying files from the linux console to a Synology NAS can be done by using SCP.
# scp [options] <source> <target>
# -P: port number (default: 22)
scp -P 8022 FHEM-20190223_162640.tar.gz fhem@my-synology:/volume1/backups/fhem
For further information about SCP commands, see:
https://www.garron.me/en/articles/scp.html
by flandersen
Posted on February 20, 2019
This tip is useful if you work with text files (e.g. log files, CSV files …) and want to delete rows containing specific keywords or patterns. Using any program that supports Regular Expressions (short regex) makes this job pretty easy.
Delete rows containing keyword/pattern:
Regex: ^.*keyword.*$
Replace: <empty string>
Delete rows NOT containing keyword/pattern:
Regex: ^(?!.*keyword.*).+$
Replace: <empty string>
Read more for an example with Notepad++.
Read Moreby flandersen
Posted on September 16, 2016
Recording the network traffic via the Wireshark GUI results in a single big file. This is unpractical for obvious reasons. By using the terminal program TShark.exe in the Wireshark program folder, you start a customized recording.
tshark -i 1 -a duration:86400 -b duration:3600 -w "c:\recordings\new.pcap"
by flandersen
Posted on December 25, 2015
The internet radio Busch-Jaeger 8216U allows to change channel via HTTP-GET.