Saturday, February 15, 2020

Separating filename from extension in bash

If we want to separate filename from extension in bash this is a neat and useful trick:

filename=$(basename -- "$fullfile")

Wednesday, January 22, 2020

Prioritization of network interfaces

If we have more than one network interfaces and want to prioritize routing via one of them we can do the following:

Check the priorities in the routing table:

/home/nickapos [nickapos@nickapos-ThinkPad-P52] [8:44]
> ip route                    
default via dev enp0s31f6 proto dhcp metric 100
default via dev wlp0s20f3 proto dhcp metric 600

Here we can see that we have two interfaces with different metric values enp0s31f6 has higher priority than wlp0s20f3, if we want to swap them we need to install ifmetric with
sudo apt install ifmetric 
and do:

sudo ifmetric wlp0s20f3 99

After this if we check the routing table:

/home/nickapos [nickapos@nickapos-ThinkPad-P52] [8:45]
> ip route                 
default via dev wlp0s20f3 proto dhcp metric 99
default via dev enp0s31f6 proto dhcp metric 100

we can see that wlp0s20f3 has higher priority so routing will happen by default through it. Only packages that can not be served by it will be routed via enp0s31f6,

Wednesday, August 28, 2019

Python patterns and antipatterns

Discovered a nice online python book about patterns and antipatterns here

Monday, April 15, 2019

Parsing and validating YAML

For anyone who is looking for ways to validate YAML files, there are multiple modules out there for python, ruby and perl.

If using pip then you can install yamllint program:
 pip install yamllint

and then do 
yamllint blah.yml

in Ruby you could do:
ruby -ryaml -e "p YAML.load("< data.yaml

Friday, March 15, 2019

Έλεγχος ποιότητας ιστοσελίδας

Σε περίπτωση που έχετε μια ιστοσελίδα για την οποία θέλετε να μάθετε αν είναι στημένη σωστά ή αν έχει διάφορα προβλήματα, υπάρχουν αρκετά εργαλεία, κάποια δωρεάν και κάποια όχι, τα οποία θα την αναλύσουν και θα σας παρουσιάσουν την ανάλυση τους σχετικά με την απόδοση και τα προβλήματα της. Μπορούν να προσομοιώσουν διαφορετικές πλατφόρμες.

Ένα απο αυτά είναι το

Saturday, October 20, 2018

Speed test site

A quite nice speed test that I used to finetune my SQM-QOS. Its all HTML5 without the need for any flash plugins 

Sunday, October 14, 2018

Resurrecting a bricked router

A couple of days ago, I tried to install dd-wrt to a top link router I purchased. I have another router of the same model which works perfectly with dd-wrt so I was surprised when the new one was bricked by the installation.

Apart from throwing it away the only alternative would be to try using the router serial port and tftp to upload new firmware.

In order to do that we need to solder the serial pins on the router board, have a serial to ttl device that will allow us to open the serial port from a computer.

I did not have a usb-ttl device so I tried to use an arduino clone I had. All of these devices that have a USB port have an internal usb-ttl that we can highjack to open a serial port. After that all we need is a tftp server to serve the new image.

The commands can be found on the internet. I tried various images the only one that worked was open wrt which was installed without problem. Not the router is working perfectly.

Here are some similar instructions for a Xiaomi router, one of the most affordable systems out there that can be loaded with OpenWrt