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:
Thoughts and ideas about programming, scripting, automation, electronics, gadgets, web and technology
Tuesday, May 14, 2013
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:
Saturday, December 15, 2012
Annotate a JPG with its EXIF date and time
If you need to annotate a bunch of JPG pictures the following simple bash script could come in handy. Script uses pictures EXIF date and time information but could be easily patched to include any other text. The only dependencies script has are Image Magic and awk:
Labels:
bash,
Image Magic
Sunday, October 14, 2012
Sunday, August 19, 2012
A little bit about Hilbert space-filling curve
As a student I have investigated properties of different scanning algorithm to unwrap an N-dimensional array into one dimensional. One of the algorithms was Hilbert space-filling algorithm. This algorithm can be applied to an array of any dimension and it is known as one of the unwrapping algorithms that preserves spatial relations between array's neighbors very well.
Labels:
3D,
opengl,
space-filling,
webgl
Monday, July 16, 2012
AVR-Stick as an infrared receiver and logger
I have already described a project based on the AVR-Stick hardware. The next thing I wanted to try with that hardware is to create an infrared receiver and logger. In fact I wanted to emulate the dongle I described some time ago. But to emulate it I needed to know the protocol that is used. The easiest way to find out what protocol is used is to analyze signals with an oscilloscope of course but I didn't have one. So first of all I needed to implement a signal logging functionality.
Subscribe to:
Posts (Atom)
![[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)
![[Image]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEij7wn8-6isQknV718kDbxmP8977k-MtJz32FsNCGy_TJxQNwfm4eK_c4r24eN9GSFfvkqbAPlyGqCfxgKs5KHJynh3cdREF3hbfWOVG_SqGA4-T3sBrra4iR1YXY3nbOIvesGVh6XAo4Y/s320/img_resized.annot.jpg)
![[Image]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ5tNdl6mWnHkH6t82vfIJBf1ujTUIxp_JDaxMLCURUQxFzE83Cy9yH3TNA9lhWEfe5CeZD0oZk0NjtYHFX4I8tlUkH4uQt913Xn_H_IvIJgCVD2p-v_sl1qR1L5jGLSTwpVJk9q8wQhE/s320/table_sizes_3d.png)
![[Image]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCuAzhIeJuHP21BngOMt_gsrOJMjF2MhRFLwa_5ywQeziSBou-DMXrogI8k2SSwCKyIo25tDqdJ01PblWioCRXkst0mXW_cs83S-XxZlKWjOWFWfATXsT26Zy_Az-IluCzKpo03fVADZU/s320/irmodule_main.jpg)