Below you will find pages that utilize the taxonomy term “Open Source”
Vanilla JavaScript, extremely good reasons you should use this to create a lean web!
July 30, 2023
Let me start with a bold statement: knowing HTML and CSS helps write much better JavaScript! Why you may ask. Well, you need to grasp the whole medium to appreciate the best approach. The what, where, how, issues etc. Vanilla JavaScript may appear daunting but it is not. Instead it is faster, more secure, and more manageable.
For the novices, JavaScript is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS.
Vanilla JavaScript, best practices
July 24, 2023
You start to work on a new project and you are happily coding away and seeing results until the number of functions, event listeners etc become too many and you have to clean up your own mess in a much more organized manner. You scratch yourself behind the ear and wonder why you did not do that right at the start…
The problem is that you only realise certain shortcomings after having done a certain number of web pages.
The future is highly distributed
October 6, 2020
In any business environment these days you almost invariably have all your data in different systems. A single ERP may be the driving force behind your organisation but having a monolithic system also limits you.
This is the reason I am very enthusiastic about Jamstack, a new standard architecture for the web. It relies on microservices, APIs to various sites to get the data from plain text files. So often you have data available but it is a pain to link it.
Static site generators
June 16, 2020
Due to my busy work schedule my personal web site was dated. So much so that it was a few releases behind schedule. I had built it using Ghost (headless Node.js CMS) and by quickly building some Docker containers I managed to upgrade the database relatively fast.
I have built many data driven dynamic sites most based on PHP or Perl. However, it was also time to re-evaluate whether to continue with Ghost.
Delete @eaDIR folders
April 23, 2018
These are index folders, the presence of which can be quite annoying.
To locate them
find . -type d -name "@eaDir" if you’re feeling ok about automatically deleting them then:
find . -type d -name "@eaDir" -print0 | xargs -0 rm -rf On a Synology NAS you can disable feature as follows
synoservice --disable pkgctl-SynoFinder warn: The runkey of service [pkgctl-SynoFinder] has been set to “No”
Is your nfs working
October 7, 2017
I use nfs quite a lot. It allows local access to remote files i.e. the remote folder is mounted locally so you can access the remote files locally.
Often overlooked, make sure the proper NFS RPC-based services are enabled for portmap (not required for nfs4). Issue the following command as root:
rpcinfo -p This should list some lines mentioning mountd.
To install nfs (here on centos):
yum install nfs-utils nfs-utils-lib Proper install details are descriped in https://www.
Open Source
November 2, 2016
The agility that Open Source produces is tremendous but only as effective as the skills of your top IT person. The learning curve is steep but tremendously rewarding. I have collected here a repository of code and other material that I have struggled with at some stage or the other. I hope it is of use. Enjoy and do spread the word of Linux.
cron errors only
April 5, 2016
If you run a cron job and you would like to only see the errors reported use cronic on Centos or chrronic on Ubuntu. The latter comes with the package moreutils
apt-get install moreutils
Search for a text string within files
October 4, 2015
At times you see that a particular image or so is not found when loading a web page and you are at a loss where the call came from. At least I had that today when I noticed that a menu image was called. The command to search for that is actually really straight forward:
grep -rnw 'directory' -e "string pattern" e.g. grep -rnw ‘public/’ -e mobile-menu.png
Minify files
October 4, 2015
I use yui-compressor to minify my files. It’s so easy. In Ubuntu (15.04) it’s available via apt-get.
To install it (on Ubuntu) type the following in your terminal window
apt-get install yui-compressor The command structure to run it is
yui-compressor SOURCE > TARGET e.g.
yui-compressor public/css/custom.css > public/css/custom.min.css
Reduce the size of a pdf
September 9, 2015
A somewhat weird but simple way to reduce a pdf is to concert it to a ps and back e.g.
pdf2ps input.pdf output.ps && ps2pdf output.ps output.pdf
Prepend and append example of a redirect file using awk and sed
August 28, 2015
I needed to generate a .htaccess redirect file where each line has a simple command
redirect 301 old-file new-file The file called crawl-error.txt with all the required urls that needed a redirect was quite long so I did the following in no time. First ensure that the file is really a proper text file as otherwise whatever you want to append will be prepended instead.
dos2unix crawl-error.txt Then prepend the text, in my case “redirect 301 “, and output the result to .
Two git repositories on the same server for a single user
July 19, 2015
I discovered that it is not possible, at least not for the same user, to have two git projects in the same account as github uses the ssh key to identify your repository. Once I realized that this was the problem, the quick fix was to clone the repository in another account. I created a new user and set it up from there. I created a ssh key which I copied across onto the github site.
ODBC link with a database
June 10, 2015
I have a web server which needs to link to a MS SQL server (not my choice). In my case I use Plack which calls the database in four steps. The catch I often struggle with is that some other files with the same name may float around and which you may not be aware off.
Run therefore a “find / -name odbc.ini” to double check this. Ditto for the others.
Wireless not working in Ubuntu 14.04
October 7, 2014
I did a fresh install the other day of Ubuntu 14.04 on a little notebook for my daughter. All worked out of the box with the exception of the wireless which had worked before using version 12.
The following terminal commands may give you a clue as to which network controller you have.
iwconfig lspci -vnn | grep Network All I had to do was install a driver and reboot
File encryption with ccrypt
July 13, 2014
No doubt you have, like me, one or more documents that you would like extra protected. How can you remember all your passwords, access codes, urls etc which you know you should not have available in plain text. In Linux there are several tools that make file encrypting easy.
I like to use a little tool called ccrypt for its simplicity. Having said that, it uses an algorithm known as AES, with 256-bit considered an extremely powerful encryption method.
Moving mail to Google Apps
September 29, 2013
After my server was attacked and brought down by the Chinese I wasn’t certain whether or not the machine was compromised. I decided though to move my mail to Google Apps instead, preferring a good sleep over worries of another more ferocious attack.
As my mail wasn’t on a live machine I could not use Google’s suggestion of using their API. Copying mail using both accounts in Thunderbird would have been a great manual effort but I also noticed it to be highly unreliable for large folders so I swiftly gave that up.
Public key without a password as a non root user
September 29, 2013
After the Chinese attacked my system trice recently I am a bit paranoid about securing my system. I used to sync data using rsync which uses ssh. However, using this as root is not a good idea hence I decided to use rsync as a non-root user without a prompt for a password. This post is therefore an update from the one I wrote almost exactly two years ago.
First the essentials
Error: Postfix/amavisd - connect to 127.0.0.1[127.0.0.1]:10024: Connection refused
August 28, 2013
You use a Postfix setup with amavisd-new and get the following errors in your mail log:
status=deferred (connect to 127.0.0.1[127.0.0.1]:10024 Connection refused)
The solution is to restart both amavisd-new and Postfix and then check with
netstat -tap that both are running on the ports 25 and 10025 (postfix) and 10024 (amavisd-new).
Error: unexpected RCODE REFUSED
August 28, 2013
If you get many of these in your massages log, it is as a result of spammers hitting the mail server with bogus domains and the DNS is trying to resolve the IP to the domain, it is coming back false, and the mail server drops the message as designed.
To avoid these message, though I like knowing what happens, add the following in the logging section of named.conf
category lame-servers {null;};
500 error on uploading large images
August 15, 2013
I noticed a strange error while uploading files. My server does not allow any file to be uploaded above the 128kb, even when the settings in /etc/php.ini are set to higher sizes.
After a lot of searching I managed to find the solution: add the following to the file /etc/httpd/conf.d/fcgid.conf :
FcgidMaxRequestLen 1073741824 Don’t forget to restart the apache server.
Set up Perlbrew
April 11, 2013
HTML development work often is done remotely with all dangers of messing up a production version. My friend Gurunandan Bhat suggested I set up a local development environment. As always all credit goes to him for his support.
This is therefore a howto for anyone eager to set up a local development environment for a dynamic web site. For that we use Perlbrew, Dancer, Plack, Template Toolkit, Memcached.
Perlbrew is a tool to manage multiple perl installations in your $HOME directory.
How to use GIT
April 11, 2013
Set up a git account on github.com. Upload your ssh key. To verify this is done click on top right Account Settings, then ssh keys on left. Then proceed to create a repository on Github. Don’t add a README.
On your local machine, go into your application folder. Type
git init This creates a .git folder inside the application folder.
git commit -m "Initial Commit" This will come back with nothing added to commit but untracked files present (use “git add” to track).
Currently unreadable (pending) sectors
March 17, 2013
I have been receiving alerts from root that “Device: /dev/sda [SAT], 4 Currently unreadable (pending) sectors”. As all my data is backup properly I don’t worry about it. Googling it, I didn’t find a straight answer for this.
smartctl –all /dev/sda | grep -e “Reallocated_Sector_Ct” -e “Current_Pending_Sector” -e “Offline_Uncorrectable” -e “UDMA_CRC_Error_Count” -e “Hardware_ECC_Recovered”
The output is as follows:
[root@myhome ~]# smartctl –all /dev/sda | grep -e “Reallocated_Sector_Ct” -e “Current_Pending_Sector” -e “Offline_Uncorrectable” -e “UDMA_CRC_Error_Count” -e “Hardware_ECC_Recovered” 5 Reallocated_Sector_Ct 0x0033 200 200 140 Pre-fail Always - 0 197 Current_Pending_Sector 0x0032 200 200 000 Old_age Always - 4 198 Offline_Uncorrectable 0x0030 200 200 000 Old_age Offline - 0 199 UDMA_CRC_Error_Count 0x0032 200 200 000 Old_age Always - 0
Rename photo file names
March 16, 2013
Normally your photos in your digital camera are saved with some number which says very little and may conflict with the next batch after you clear your memory. One of the best programs I have ever used to rename my photos is jhead. This takes the date when the picture was actually taken. Fabulous! Try it out, I promise you won’t regret it.
jhead -n%Y%m%d-%H%M%S * One improvement would be to add the gps coordinates but my camera is not that fancy as yet.
Last reboot
March 16, 2013
Want to know when your server rebooted lately? Simple
last reboot or in case you really only want to see the very last one do
who -b
prompt colour
March 16, 2013
As I often work on multiple servers it is rather dangerous that one give a command on the wrong server. To minimise the risk it is good practise to colour the terminal prompt by adding this at the end of the ~/.bash_profile file.
export PS1="\e[0;32m\u\e[m\e[0;32m@\h\w \$ \e[m" and something like this in the root of the same server (i.e. you highlight root red vs home green)
export PS1="\e[0;31m\u\e[m\e[0;32m@\h\w \$ \e[m" The numericals for the various colours you can use are:
Mailman
February 26, 2013
I was looking at creating a simple alias to enable to send a mail out to everybody. My first thought was to set an alias in /etc/aliases but that didn’t work as the email is was not recognized by postfix. I use ISPconfig, the latest version of which is supposed to support mailman. Hence I thought to quickly install that but ran into some minor problems. The main problem being that Google shows very few posts related to my problems.
Change ownership among users
December 11, 2012
When an employee leaves you may want to pass on the ownership of his/her files to someone else. To do that simply give the following command:
chown -cR --from:olduser newuser:newgroup *
Samba logging
December 10, 2012
A staff member came to me to state that his Yahoo account had been hacked from our company account, or so he claimed. This made me look at the samba logs and realise that user logging was not actually implemented while it is relatively easy to do so.
This is used on Ubuntu 11.04 but the same should more or less work on any other system.
Edit the Samba configuration file and add the following
Adding a service permanently
November 15, 2012
systemctl enable name-of-the-service
To use Samba as an example
systemctl enable smb.service systemctl enable nmb.service systemctl start smb.service systemctl start nmb.service All that the first command does is create a symlink
ln -s ‘/usr/lib/systemd/system/smb.service’ ‘/etc/systemd/system/multi-user.target.wants/smb.service’ Thus /etc/systemd/system/multi-user.target.wants contains all services that need to start automatically.
Tape Backup
October 23, 2012
To make a tape backup, give the following two commands on the terminal of the Felicity Linux server. The first one rewinds the tape to the beginning and the second one makes the actual backup. Just cut and paste the following two lines, press enter, and leave it for the machine to do the backup.
mt -f /dev/st0 rewind tar -cpzvf /dev/st0 /home/ So only the /home/ directory is being backed up.
HandBrake
October 14, 2012
I have a Sony home theatre and I have been bugged for ages as only some of my video files where showing up. A real bummer. After lots of searching and trying different programs, which all had some issue, I bumped into handbrake.
Before you try and install handbrake on Fedora 17 first install the following packages
yum groupinstall "Development Tools" "Development Libraries" "X Software Development" "GNOME Software Development" yasm zlib-devel bzip2-devel fribidi-devel dbus-glib-devel libgudev1-devel webkitgtk-devel libnotify-devel gstreamer-devel gstreamer-plugins-base-devel
how to teach spamassassin
October 12, 2012
Apply sa-learn to all email boxes called Junk in a cron job
/usr/bin/sa-learn --spam /var/vmail/*/*/.Junk/*/* /bin/rm -rf /var/vmail/*/*/.Junk/cur/*
Concatenating pdfs
October 8, 2012
Use Ghostscript to contatenate pdf files:
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf
Postfix problems
September 24, 2012
For some reason my postfix installation went totally wrong. I don’t know why other that I suspect that my IT manager may have given the wrong command and in his enthusiasm messed things up.
I didn’t see much of an option but to reinstall postfix but that turned to be a lot harder than expected as aptitude insisted to install exim as a replacement which it couldn’t do. No matter what purge postfix etc I tried, I was stuck.
Uploading a file in Mediawiki
September 18, 2012
Uploading a file is easy if you see the upload link. I didn’t.
To ensure you see it you have to change the setting in LocalSettings.php
$wgEnableUploads = true; You may get an error **Could not create directory “mwstore://local-backend/local-public/ **and some more alpha characters. This turned out a simple permission problem. You have to set the permission of your images directory to 777
chmod 777
Is it a 32 or 64 bit machine?
September 16, 2012
To find out whether the pc you are working on is actually a 32 or 64 bit machine you have to give the following terminal command:
uname -m If it displays i386 or i686 then it is 32 bit. x86_64 is a 64 bit machine.
Changing date format in Thunderbird
August 15, 2012
Create a small bash file
vi ~/thunder and cut and paste the following in it.
#!/bin/sh export LC_TIME=en_GB exec /usr/bin/thunderbird "$@ Then make the file executable and edit the launcher
chmod 774 ~/thunder gnome-desktop-item-edit /usr/share/applications/mozilla-thunderbird.desktop and replace the command with ~/thunder i.e. the path of the above file.
Note: unfortunately you will have to repeat the last command after each upgrade
HTTP not working
August 8, 2012
I was surprised that apache didn’t work out of the box. Thanks to DoomDeathMetal (what a name!) this was easily solved:
rm -rf /etc/httpd yum -y reinstall httpd systemctl start httpd.service
Backup script
August 8, 2012
I use rsync for all my backup scripts. It is fast and easy.
#!/bin/bash LOGFILE=/var/log/backup.log EMAILID=Alfred Tuinman@xyz.com NASDISK=192.168.x.x:/volume1/backup/myserver # the NAS station ARGMNTS="-rptgoDLKve ssh --delete-excluded --safe-links --exclude-from=/path-to-my-file/rsync_exclude" ERROR=0 log='' # for a daily copy on weekdays (5 copies) if [ `date +%u` -lt 6 ]; then weekday=`date +%w-%A` else weekday='5-Friday'; fi # for rotating every day (2 copies) uncomment the following line in lieu of the above #if [ $(( `date +%w` % 2 )) -eq 0 ]; then weekday=1 else weekday=2 fi command="/var/vmail/ $NASDISK/$weekday/var/vmail/" echo "syncing $command" if rsync $ARGMNTS $command then log="$log `date +%d-%m-%G\ %k:%M:%m` | `basename $0` | Synchronised | $command " else ERROR=1 log="$log `date +%d-%m-%G\ %k:%M:%m` | `basename $0` | Error | $command ($?
MP3
August 8, 2012
You have to add the repository to be able to get plugins for mp3
yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm Then ad the actual plugin
yum install gstreamer-plugins-ugly gstreamer-plugins-bad-nonfree
Adding Java to your Firefox browser
August 8, 2012
Sometimes Java isn’t installed by default. To add it
sudo apt-get install icedtea6-plugin
Adding a GUI to your Ubuntu server
August 8, 2012
I know that you don’t need a GUI op a server but sometimes you are in a small business environment where the people having to use it are not that familiar with a terminal. If you install ubuntu-desktop you overkill it by installing all user software packages like office, some games,gimp, etc which of course will also take ages. The following will set us a basic gui quickly.
sudo aptitude install --without-recommends ubuntu-desktop
Virtualbox
August 8, 2012
I did try to in vain install vmware so I changed to virtualbox. There I got the following error:
“Windows failed to start. A recent hardware or software change might be the cause. To fix the problem: 1. Insert your windows install disk and restart the computer. 2. Choose your language settings, and then click NEXT 3. Click repair the computer.
To avoid this, click on Settings tab of the Virtualbox.
Cron working but not executing?
August 8, 2012
I was struggling to understand why cron, which was running ok, was not executing my file in /etc/cron.hourly/hourly.backup while if I would run this script by hand it was working file!
The reason is that cron doesn’t like a dot in a filename (at least in Ubuntu)
Logging
August 8, 2012
It is handy to have cron log to /var/log/cron.log. You can change this setting in
sudo vim /etc/rsyslog.d/50-default.conf You will need to restart the services
sudo service rsyslog restart sudo service cron restart
Permission on main Samba folders
August 8, 2012
I always set the permissions for the main shared folders in samba to 3770. This way any files made below this will inherit the group ownership of the parent.
ntsysv in Ubuntu
August 8, 2012
I always thought this was such a handy utility. In Ubuntu there is something similar to check if services are set to start at boot up.
apt-get install sysv-rc-conf
Changing the main menu (sidebar)
August 7, 2012
in mediawiki change the url suffix to
http://my-domain.com/my-wiki/index.php?title=MediaWiki:Sidebar&action=edit
Sorry! This site is experiencing technical difficulties.
August 7, 2012
This error happened to the mysql user and password not being correct on file. Change the setting in LocalSettings.php. You can verify whether the details you have are correct by logging into the mysql database
mysql -u ''wikiuser'' -p ''wikipassword'' where of course you have to replace the user name and password with your own details.
Access denied for user ‘debian-sys-maint’@'localhost’
August 7, 2012
debian-sys-maint is a system MySQL user created to be able to start/stop the databases and to carry out maintenance operations. The above error message is therefore due to a mismatch between the mysql debian-sys-maint password in the mysql database and that in the configuration file /etc/debian.cnf. Check and copy the password on file:
cat /etc/debian.cnf log into mysql
mysql -u root -p set the mysql database password for debian-sys-maint to that as on file in the /etc/debian.
Unable to start piped log program
August 7, 2012
unable to start piped log program ’ /usr/local/ispconfig/server/scripts/vlogger -s access.log -t “%Y%m%d-access.log” -d “/etc/vlogger-dbi.conf” /var/log/ispconfig/httpd’: No such file or directory Unable to open logs
This happened after I deleted ISPConfig3 which for unknown reasons I could not get to work out of the box. I checked the contents off all the other apache files and bingo I found the culprit.
cat /etc/apache2/sites-enabled/000-ispconfig.conf |grep vlogger ISPConfig Logfile configuration for vlogger CustomLog “| /usr/local/ispconfig/server/scripts/vlogger -s access.
Synology
August 7, 2012
The SynologyAssistant had worked out of the box on Ubuntu but for FC17 I had to do some extra work. First of all I had to add quite a few packages:
yum install libXt.so.6 libXext.so.6 libfontconfig.so.1 libXrender.so.1 libSM.so.6 libgobject-2.0.so.0 libfreetype.so.6 libstdc* glib glib-devel glib2 libqwt In the firewall I added eth0 as a trusted device.
FC17 uses bios device names like p17p1 rather than NIC names as eth0. Not sure whether that matters but I changed it to the old nic name by appending ”biosdevname=0” in the command line starting with the word kernel in grub.
HP printer and scanner
August 7, 2012
I use xsane which needs to be added as well as some other development packages
yum install xsane gcc cups-devel python-devel libusb-devel libtool libjpeg-turbo-devel qt4 qt4-devel pyqt4 pyqt4-devel dbus-devel Run hp-check to see if you have all the required packages covered
hp-check I still haven’t got my scanner to work
Flash in Firefox 14
August 7, 2012
For my Adobe flash plugin to work I had to install a few extra packages
yum install flash-plugin nspluginwrapper alsa-plugins-pulseaudio libcurl also the plugins for mp3 etc
gstreamer-plugins-bad-nonfree
Show my desktop
August 7, 2012
While it may be nice to see a clean desktop I do find it handy to keep my current work load there. To show that again follow these menu options
Activities -> Applications -> Advanced Settings -> Desktop -> Have file manager handle the desktop
Show the date in the clock
August 7, 2012
Activities -> Applications -> Advanced Settings -> Shell -> Show date in clock
MySQL backup and restore
August 7, 2012
To backup a single database:
mysqldump --user=root --password=password mydb > mydb.sql Yes it is no typo, there is no space between the -p and the password!
You may like to add this to the my.cfg file in etc to avoid
[mysqldump] events ignore-table=mysql.events If you didn’t use the –all-databases option but instead selectively backed up one or more tables or databases, you need to tell MySQL which database to place them in when restoring them.
Change permissions on files only
August 7, 2012
find . -type f -print0 | xargs -0 chmod 444
Change the type from f to d if you only want to change the permissions on the directories, Plus the permission of course.
find . -type d -print0 | xargs -0 chmod 755
List all files starting with upper case
August 7, 2012
find . -type f -name ‘[[:upper:]]*’
If you want to change files to all lower case, e.g. your mp3 music files then run the following script. The -i option for the mv command stands for interactive, i.e. it will prompt for your approval.
#!/bin/sh if [ $# -eq 0 ] ; then echo Usage: $0 Files exit 0 fi for f in $* ; do g:`echo $f | tr "[A-Z]" "[a-z]"` echo mv -i $f $g mv -i $f $g done Thanks to Anil Awasare for this script
Update a Mediawiki
August 7, 2012
Download the new mediawiki from their website to the html directory
wget http://download.wikimedia.org/mediawiki/1.17/mediawiki-1.17.0.tar.gz Extract the download and type
tar -zxvf mediawiki-1.17.0.tar.gz to extract the file to the current directory. Rename the extracted directory to something easier
mv mediawiki-1.17.0 update Copy the images directory and LocalSettings.php from the old to the new wiki
rsync old_directory/images/ update/images/ cp old_directory/LocalSettings.php update/LocalSettings.php Backup the old directory
tar -zcvf archive-name.tar.gz directory-name Remove the old directory
Enter password to unlock your login keyring
August 7, 2012
If you get this irritating pop-up all the time, go to programs and type “Password” a program utility called “Password and keys” will be displayed. Right click on the displayed item called “Login”. This will ask for the old and new password. If you have not changed your user password, just enter the current password for both old and new.
Change to Fedora 17
August 7, 2012
Recently I installed Ubuntu 12.04 server only to find that the samba server was horribly slow. I replaced it with Fedora 15 and it runs like a train. Yes, I know 15 is an old version but for a production site you don’t want the latest bugs. Also, howtoforge has a stunningly good article on how to set up a perfect server.
Minimize and re-size buttons So I have been working with older Fedora desktop versions before but FC17 threw me a bit.
Strip HTML code
April 22, 2012
Use the sed terminal command with an input file called say test.html
sed 's/<[^>]*>//g' input.html if you want to save the output just do the following
sed 's/<[^>]*>//g' input.html > output.txt
Selecting software for a greenfield
June 27, 2010
Centos
Published in Dare magazine, August 2010
I am writing this using Open Office on a laptop with Ubuntu as it’s operating system, the Open Source equivalent from Oracle of Word and Windows respectively. My exposure to Open Source dates back to the 1990s. At that time I was a Director Finance & IT of Odyssey Tours, the famous travel company. Frustrated with continuous maintenance problems with Windows I was looking for ways to reduce this.