Convert all htaccess files to httpd.conf directives


This post is for the Apache web server, I created a simple script that will do the job. You may use it in Wordpress or in many CMS, surely this script will be useful in a lot of situations. It will help you to increase the speed and security of your site. Requirements: root access.

#! /bin/bash
b=$(find $1 -name .htaccess)
for p in $b; do if [[ -s "$p" ]] ; then a=$(dirname $p); echo \<Directory \"$a\"\>; cat $p; echo; echo \</Directory\>; echo; fi; done

You only have to specify the website directory and it fill search for all .htaccess files in sub-directories, then it will print the directives for the httpd.conf file, you can invoke the script like this:

./script.sh /var/www/html


Add the resulting configuration manually to httpd.conf and don't forget to add AllowOverride None to the root directory, in this way my website speed increased noticeably! Also security increased. Please notice that you may end with a duplicated entry for the base directory, so please check it carefully. I read that a hacked website may include malicious code in the .htaccess files, so please check the code before adding into the config file.


All system messed when installing an application


It has been a while since the last time I did a whole system update in Slackware, this time I tried to install audacious, an audio player included in the official repos, the first thing to do was updating the list of files:

slackpkg update

Then I installed audacious:

slackpkg install audacious

At certain point it seems that it asked me to replace configuration files. It messed with my whole system. Installing just an application messed with all my /etc directory. So my advice is that you always check the configuration files that will be updated no matter what you are doing or the distro you are using.

How I solved it?

The next day I realized that I had lots of .orig files in /etc. So I restore all my important config files.

find /etc -name *.orig

Notice that I lost my /etc/rc.d/rc.local , there was not an /etc/rc.d/rc.local.orig


Script for concatenation


Here a tip for using split and cat, you can use this simple bash script for concatenating the pieces of the file, first you have to change the current directory to the one with the current files part.

You will be asked by the base name and the extension of the file. Easy!

#! /bin/bash
read -p "Base name: " basi
read -p "Extension: " ext
cat $(ls $basi*) > $basi.$ext

Site announcements.


I lost my domain rpm.li, but I got zsh.li instead. Did you know that the dot li domains has to be renew 15 days before the expiration date?

The blog was moved from pinkhat.rpm.li to pinkhat.zsh.li

Also cat.rpm.li was moved to cat.zsh.li and the public link shortener was removed.

The Screenshot in https://pinkhat.zsh.li gallery was removed and will be included again in a more traditional way.

The home page is now very minimalist and includes links for all sites.

I tried to include bitcoin based advertisement, but I didn't liked because it makes the load of the sites slower, Advertisement it's like politics and religion, polemic.

Lately I been working in increasing the efficiency of the site instead of creating content, but there will be new posts and content soon.


Using QR codes for coding files and text


The other day I discovery how change the Guard node (Entry node) in Tor for the Tor daemon, just delete all the files in /var/lib/tor/. This is a bad thing to do, for more information search in Duckduckgo.

Today we will learn how to use QR codes for encoding files. Sometimes we use virtual machines that have no means to interact with the host machine. Maybe due to security concerns or you don't want to mess with config files and command line options. Or simply because you are only allowed to send pictures but no files.

Whatever is your reason, you must be truly desperate to use it as this method is only limited to 3000 characters.

I also tried with OCR software, but that was a pretty bad idea, the QR codes works just well.

Let's we suppose that we want to encode a text file as QR pictures, these are the steps. You should use the base64 command for non plain text files (base64 binary > file.txt)

Step 1. Install zbar where you will decode the text.

You can find it in Ubuntu as zbar-tools and is available in AUR as zbar-headless. In AUR you will also found the QT and GTK version.

I actually compiled it manually and disabled some features at compile time as we only will need the cli.

./configure --without-gtk --without-qt --disable-video

Step 2. Install qrencode

Install this in the place where you will generate the QR pictures. This application is available in the Debian/Ubuntu and Arch repos.

Step 3. Split the file

This step is need only if you need to split the file in several parts as the limit is about 3000 characters With the following command you can split a file by number lines.

split file -l number

You can count the total lines with the following command

wc -l file

Step 4. Create the QR

Execute the following command in the same directory where you split the file:

for p in {a..z} ; do ( cat xa$p | qrencode -o qr$p.png ) ; done

Step 5. Decode the QR codes

Before continue you have to take pictures to the qr codes or taking screenshots, and then rename the pictures with their original names. Then cd to the directory containing the qr pictures.

for p in qr*.png ; do ( zbarimg --raw $p | sed '$ {/^$/d};' ) > ${p%.*}.txt; done

Step 6. Concatenate the files

cat qr*.txt > file

This method works if the qr images are being saved in the target machine with the same name as the source machine.