So you need to convert a bonch of FLAC files to mp3 and your best search engine only recommands you online file converters that nobody trusts ore require a paid subscription to work. Don’t worry, there’s always a way, and even better, a true hacker style way to achieve this! This procedure works for MacOS through Brew, but you should be able t... Read more
20 Feb 2019 - less than 1 minute readHere’s a small script to open a JavaScript interface to interact with an IoT device. This interface can then be easily incorporated in a larger Blockchain project with real tangible everyday life objects. I’ll cover the Blockchain aspect of this project in another article, focusing on Hyperledger. The IoT device I’ll be using for this project i... Read more
20 Aug 2017 - 2 minute readHere’s a small script to compress JPEG images in a folder. Useful to save a few kilobytes of bandwith when serving images from your website. I might improve this script in the future to include more compression tools and/or file extensions. #!/bin/bash for f in *.jpg *.JPG *.jpeg *.JPEG do echo -en "Converting ${f} ... " kb_orig=`du -... Read more
20 Jul 2017 - less than 1 minute readOk, that’s a simple one, but it’s always nice to have a quick syntax remainder. So, here’s the best way to compress a whole directory under Linux/UNIX using a shell prompt. This technique is often used to backup files or to move data using a compressed archive. The GNU tar command is best for this work. This command does two things for you: ... Read more
20 Jun 2017 - 1 minute readI have been using the Secure Copy (scp) utility for copying files between my local server and development server. Sometimes I have to copy more than one file. Copying each file can be very annoying, as you have to type the password every time you use the command. But it is possible to copy multiple files using scp, just like the copy (cp) utilit... Read more
20 May 2016 - 1 minute readGNU Screen is a very useful tool to run a long script on a server and make sure the script will run even if your computer gets disconnected, runs out of battery or whatever. In this article, I’ll assume you’re already familiar with the basic concepts of GNU screen, and I’ll just provide you with some tips that I use to make this tool even more ... Read more
20 Oct 2015 - less than 1 minute readHere’s some piece of code to use on a cron job when you have a software component (database or application) that spits out logs and you want to archive or delete those files based on creation date. #Archive find log/ -type f -mtime +681 -ls -exec mv {} log/2011/. \; #Delete find . -type f -mtime +30 -ls -exec rm {} \; Read more
20 Jul 2015 - less than 1 minute readIn this article, I’ll demonstrate multiple solutions to move datafiles Method 1: using symbolic links Stop the Mysql instance. /etc/init.d/mysql stop Then move the files and put symbolic links to lure Mysql into thinking the files are still in place. mkdir /new_dir/datafiles/my_db cd /old_dir/datafiles/ cp -Rvp my_db/* /new_dir/datafiles/my_... Read more
20 May 2015 - less than 1 minute readEventually, you’ll need to automate queries on your Mysql database, let’s say, for reporting purposes. Hee’s how to put SQL queries into a shell script, and possibly including variables based on the date or whatever fits your needs: $ cat execmysql.sh #!/bin/sh ids="3,4" table="NMS.main" qry="select id,data from $table where id in ($ids)" echo ... Read more
20 Sep 2014 - less than 1 minute readThe command-line tool SCP can be effectively used to move files and perform file compression in the transfer. However, there’s different ways to achieve this, with different results. Here are a few axamples with different results: To copy & compress in a single line gzip -c test_arch.arc | ssh user@new_serv "cat > /home/oracle/backup/b... Read more
20 Apr 2014 - less than 1 minute read