How to make a script sleep for a random amount of seconds

Reading Time: < 1 minute

If you want to insert a sleep in a script for a random number of seconds, you can do the following:

        NUMBER=$[ ( $RANDOM % 60 )  + 1 ]
        sleep $NUMBER

Replace 60 with the interval chosen and you will get a random sleep between 1 and 60 seconds.

This can be useful if you are trying to fetch data from a server who’s monitoring the number of connections you are opening and tends to blacklist you if you do too much.

How to crash a linux server

Reading Time: < 1 minute

Easy!

You need to execute this as root.

First enable SysRq feature in the kernel
echo “1” > /proc/sys/kernel/sysrq

Then crash the kernel (makes a kernel dump)
echo c > /proc/sysrq-trigger

Reboot with no conditions (no disk unmount, just like pressing reset button)
echo b > /proc/sysrq-trigger

Shutdown all the processes gracefully except init
echo e > /proc/sysrq-trigger

Kill all the process brutally except init
echo i > /proc/sysrq-trigger

How to record almost like a pro

Reading Time: 2 minutes

There is one very simple way to take your elearning module to the next level. Recording.

Recording almost like a pro means, several things:

– the right voice

– no noise

– the right pace

For the right pace, there is a lot to say but that is not the topic today. What I want is to give you a couple of tips you will find useful to create quality recording on the cheap.

– the right voice

Some people say I sound very well when I record myself. Truthfully I started to think so when people said it. I would have never started recording myself if nobody else would think my voice is good for recording.

I think most people can record themselve. I don’t think there is a bad voice and a good voice. It’s a matter of how you articulate, the noise, the technique. Not the texture of the voice. So if you sound like a screeching bird, keep faith, there is hope!

– no noise

That’s where there is usually room for improvment.

First, you really need a good microphone. I bought a Samson Meteor mic. It’s awesome. I just have one problem with it, the first time I showed it to my colleagues, they were wondering what I was doing with a dildo…

The sound of this mic is just fantastic and it costed me 100 euros.

https://www.samsontech.com/samson/products/microphones/usb-microphones/meteormic/

When you are recording yourself you may have to hit the keyboard, if you do a screencast, you may have to click, etc. These little noise can be captured by the mic and it may even be necessary to give a sense of reality to your performance, but it can also create loud banging noise every time you hit a key.

So here a little piece of advise. Find another table and put the mic there. Or find something like a laptop pouch, a backpack, whatever soft and big you may have and put the mic on it.

That’s my setup and it works. You can also put a pullover under, a coat or whatever you have close by.

Also make sure the CPU fan is not blowing directly towards the mic. That would mean more noise to get rid off in post production.

– Microphone orientation

One of the most annoying thing in amateur audio recording is Ps and Bs popping. Some people will sell you expensive screens to prevent them Some other people will teach how to make one yourself. But the true real way to get rid of them without investing anything is to setup your mic properly.

Just make it point upwards and don’t speak directly towards it. Direct your speech slightly  to the side of it. that way you will not create bursts of air

 

How to forward a lot of emails with Mutt

Reading Time: < 1 minute

Today I had to forward 2200 emails from a mailbox to another address. I looked around a bit to find a way to automate this process but all I could find was how to forward new messages.

That’s easy, just put a .forward file in your home dir with the email where you want to forward and it works.

But to forward already received email, it’s a bit trickier.

I was already using Mutt and I know it is a very powerful tool so I looked a bit more into it.

In order to solve my problem I found the following:

You can Tag many messages with this command:

T.*

Then execute one command on all the message tagged with this:

;b

It will then ask you the email address where to bounce all this emails.

Fill it in and off you go. It took 3 minutes to send the 2200 mails. Cool 🙂

Then you can easily delete all these files with this:

;d

Moodle installation problem

Reading Time: < 1 minute

I just installed moodle on my server and got into a big mysql error complaining about binlog and other stuffs…

Cannot execute statement: impossible to write to binary log since 
BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine 
limited to row-based logging. InnoDB is limited to row-logging when 
transaction isolation level is READ COMMITTED or READ UNCOMMITTED

After a bit of googling and understand what this was about I figured I should add the following in my my.cnf file and then restart mysql.

How to download a youtube video under linux command line

Reading Time: < 1 minute

Here is a great python script very useful to download an HD video from Youtube using the command line in Linux.

https://rg3.github.com/youtube-dl

It’s very simple, download and run. The result is an mp4 file that you can watch offline with VLC or Media Player Classsic under Windows or any other mp4 player under Linux.

Fix a ubuntu upgrade problem with Grub2

Reading Time: < 1 minute

With Ubuntu 10.04 came a new version of Grub. During an upgrade from a previous version to 10.04 or higher there will be a time when the system will ask you if you want to keep your own version of the configuration or get the package maintener version.

If I am not mistaken, you should say you want the maintener one.

But then something strange may happen depending on your upgrade path.

How to connect to someone out of your network on Linkedin

Reading Time: < 1 minute

These days I am looking for a web developer in Lithuania. It is not very easy because it’s a small country… but on Linkedin you can find quite many profiles.

The problem is, sometimes you can’t connect to these people because they are too far out of your network.

Usually you would get the first name of the person and some skills in his profile.

How to get the value of the latest auto-incremented value on a mysql table with concurrent connections

Reading Time: < 1 minute

When building a web application it can seem a bit tricky to get the value of the id (primary key) of the latest row inserted in a mysql table.

It is not that complicated.

The function LAST_INSERT_ID() can help you finding that. This function will return the latest auto-incremented value. No need to specify the table, it just takes the latest one.

SELECT LAST_INSERT_ID() ;

The next question is: what happens when I have many concurrent sessions on the same server? Will I get the latest inserted id from another user?

install a lamp server on ubuntu

Reading Time: < 1 minute

Easy!

sudo apt-get install lamp-server^

Be careful not to delete the ^ character.

This will install: