Coding Blog

“Never memorize something that you can look up.”
#Einstein

Jekyll build and serve commands

by flandersen

Posted on February 23, 2019

I use Jekyll to create my webpage.

# 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 More

Start Python in virtual environment

by 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, though, which isolate a complete guest operating system from a host system.

# goto project directory

cd my_project

# create virtual environment

$ python3 -m venv .venv

# activate the virtual environment

source .venv/bin/activate

# 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/

Read More

Git - Merge branch into master

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 More

Copy files from Linux console to Synology NAS

by 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

Read More

Delete text rows using regular expressions

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 More

Long-Term recordings with Wireshark

by 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"
Read More

Change channel of Busch-Jaeger via HTTP-GET

by flandersen

Posted on December 25, 2015

The internet radio Busch-Jaeger 8216U allows to change channel via HTTP-GET.

Busch-Jaeger 8216U INet Radio

Read More