Sometimes I want to redirect bash output directly into an X application for further editing. Normally this is done using a temporary file where the bash output is saved and then it is opened by an application. There's a way though to start an X application and paste the bash output into its window automatically.
Thoughts and ideas about programming, scripting, automation, electronics, gadgets, web and technology
Saturday, August 10, 2013
Tuesday, July 23, 2013
Python vs Perl vs Lua - speed comparison. Part 2
As far as people show interest in this topic I decided to perform an additional measurement to the one I performed in Part 1.
This time I wanted to compare floating point numbers operations performance because my good friend Anonymous worried about it. He said that I shouldn't have abused lua interpreter with basic arithmetic operations on integers because it's not good at it. He said that I should have tried floating points numbers instead to let lua interpreter shine. I was a bit skeptic about it to be honest but Anonymous's logic was sound.
Monday, July 22, 2013
Thursday, July 4, 2013
Tuesday, May 14, 2013
Python vs Perl vs Lua - speed comparison
I have written the base64 encoding algorithm in Perl, Python and Lua to compare the performance in basic arithmetic and file-io operations. Perl implementation was written a long time ago and it supposed to be a one liner. That's why the script looks so obfuscated:
Saturday, May 11, 2013
Using ssmtp to send email notifications
I've been using ssmtp for a long time to send automatic notifications from all my embedded systems like routers or NASes and also to send anything from a command line to a desired email address. The program is only 8K (whereas mutt is 3.5M) but it can handle secure TLS/SSL connections to SMTP servers. Setup is very easy as only one file has to be adapted. Please read this tutorial to set the ssmtp up.
To make it easier to use I have written a bash script that handles email header creation and adds a simple command line interface:
Monday, May 6, 2013
Minimal Xubuntu Desktop installation
Edit: I strongly recommend to continue with the Xubuntu 13.10 installation because many steps described here are obsolete.
I spent a day building a minimum Xubuntu installation to avoid bloat-ware installed by default. I was installing Xubuntu on a small 16GB SSD that was used previously as an ExpressCache drive on Windows 7 and that's why I wanted to install minimum set of software for the Desktop to work.
As the basis for the system I've chosen Ubuntu 13.04 mini.iso. My first attempt was to install Debian Sid branch but software there is already outdated! And installing new software from experimental branch is not possible as apt-get would completely destroy installed Sid system.
Monday, April 15, 2013
Vacuum cleaning of $HOME to back it up
I've started with a simple script to compress Firefox's sqlite databases before creating a backup of my $HOME directory
alex@xubuntu:~$ cat bin/vacuumFirefox.sh
#!/bin/bash
[ -n "$(pidof firefox)" ] && {
echo "ERROR: firefox is still running, close it first!"
exit 1
}
counterBefore=0
counterAfter=0
for i in ~/.mozilla/firefox/*/*.sqlite; do
fileSizeBefore=$(du -b $i|awk '{ print $1 }')
counterBefore=$((counterBefore + fileSizeBefore))
sqlite3 "$i" vacuum
fileSizeAfter=$(du -b $i|awk '{ print $1 }')
counterAfter=$((counterAfter + fileSizeAfter))
echo "$fileSizeBefore $fileSizeAfter - $(basename $i)"
done
echo "Bytes saved: $(( counterBefore - counterAfter ))"
Here is a sample output:
Thursday, March 28, 2013
Ubuntu with the NetworkManager as a NAT gateway
Sometimes I use my Xubuntu notebook as a NAT gateway for my Windows 7 computer because its WLAN interface works in 5GHz band and Windows computer works only in 2.4GHz. So I connect my Win7 computer to my Xubuntu notebook using a crossover Ethernet cable and turn it ito a NAT gateway using a bash script.
Labels:
bash,
dnsmasq,
nat,
NetworkManager,
ubuntu
Saturday, January 5, 2013
USB to Serial TTL cable
I was looking for a cheap USB to Serial TTL cable that would have a 3,5mm audio plug on its end. Such a cable can easily be found on Amazon for 23,27€ which is just a road robbery. Having an old audio plug the same cable can be constructed for only 6€ and here is the algorithm:
Subscribe to:
Posts (Atom)
![[Image]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjoLDUubAcPfvYniQUWMm0bsbUp6YLw4E7R70vwJO8sqkb0IHAkvbqf4xlwxPxMZIAHBPMxWlxjgX4Atfpni7liaNJ5Mm0bUNLsopEkHR5d2sT-AUI_OvE58N8JP467p5QVOcQfvkJWqg/s320/zpkwindow.png)
![[Image]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheB3OCcQxyN6t5k4pWHowrPifntdl6C4YCVGsXJyigGmAOVpvX3VJr7hR3QxzjIR6bSFOcNPn4MKj9fFzcPS-9JILC8qbnVhV-9LERorfC7EOnuBoxJGAUGlp0WEY62z4ildVsWzK_s4E/s320/xubuntu_logo.jpg)

![[Image]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAf412GH4gw-y52Td70VFpRTdiBmQqsGl4AdIRJdtdV_2bmytygQSOzfjx4X8ELp4d4HbdF4eqKgHlqQVDpHOj8Um_aUFKfbVGZ52AsR0hjKrFFHPAsLipPO4pZdG3Exgrxy5wOOzUfeY/s320/usbttl.jpg)