Alex Hughes || microfeeds:

You can have them fresh on your plate everyday using your favourite feed reader: 'http://microfeed.ahughes.org/feed.php'

Special thanks to my friend and colleague Karen for the 5 minute godly touches on my horrible CSS file.

 

Restore one table from huge MySQL dump file

I recently needed to restore a single table from a huge 3GB SQL dump file.

Luckily enough, I found the following solution on Stack Overflow, but I will copy it here, to have it handy.

So, essentially, by replacing "mytable" with the actual table's name, run the following command:

sed -n -e '/CREATE TABLE.*mytable/,/CREATE TABLE/p' full_dump.sql > table_dump.sql

I may take it a step further and tell you that if you want to have any commands before the table creation, like USE myschema you should create the table_dump.sql file yourself and then append sed's contents by using the ">>" operator.

Perhaps if you still get errors, you may have to open the file with a decent editor like vim to get rid of certain lines that mysqldump creates. Still a better alternative to opening the entire dump.

A brilliant way of using sed to getting what you want.

Forcefully avoid using public keys on rsync

If for some reason you want to execute an rsync command and you want to explicitly use password authentication, instead of using your public key, the only thing that you need to do is:

rsync -avz --delete -e "ssh -o PubkeyAuthentication=no" ~/files/* user@remote:~/files/

I tend to forget the syntax, so this will act as a reminder now...

Hope this was helpful to you as well.

Adobe Flash Plugin issues in Ubuntu 14.04

I am using Ubuntu with KDE as the window manager and from time to time, every single site that uses Adobe Flash, tends to not function properly, showing me the following message:

This plugin is vulnerable and should be updated

Now this wouldn't be a problem, but if I click "check for updates" it doesn't seem to find one.

After a bit of googling, I found out that I just need to run the following command on the terminal to fix the problem:

sudo apt-get update && sudo apt-get install -y flashplugin-installer

I hope this helps, if you have got the same problem.

Cheers!

CentOS: Another MySQL daemon already running with the same unix socket

If you have ever performed a hard reboot on a CentOS server, you would have noticed that a handful of things can get a bit out of tune.

One of these things is the MySQL server daemon. It would not start automatically, and when you try using:

sudo service mysqld restart

...it gives you the following error message:

Another MySQL daemon already running with the same unix socket.

A quick method to bring your site back online, is to execute the following command:

sudo mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak

Followed by:

sudo service mysqld start

The same philosophy probably applies to other flavours of Linux, but the location of the lock file probably differs.

Java replace() and replaceAll() methods

When handling simple strings in Java, chances are that somebody will need to perform a search and replace operation.

There is a rookie mistake one can make (even if he's not a rookie anymore) using the wrong function for the wrong task, mainly because of the unusual naming convention.

For instance, today, I stumbled upon a piece of code that was using the replaceAll() function, even though this was not necessary because it could be using the replace() function instead.

What is the harm though?

The harm was that because of that, the code was buggy and was occasionally throwing the following exception:

java.lang.IndexOutOfBoundsException: No group 1 | Pattern matching

All of this, was happening because some symbols of the text were not escaped properly, and the compiler thought that I was trying to use a regular expression.

So, the million dollar question is, what is the difference between replace() and replaceAll()?

The replaceAll() and replaceFirst() are functions that use regular expressions. The replace() function DOES NOT.

This means that replaceAll() replaces all occurences, using regex. Consider it like a helper for using regex in a certain way. The replace() function, again replaces ALL, even though its name does not imply so, without using regex.

Because of the above fact, the replaceAll() needs some characters to be escaped in the supplied String, otherwise they will be mistaken for a regex, throwing various annoying exceptions.

So, if all you need to do is a simple find and replace operation without messing with regex, use replace(). It is slightly faster and a lot more foolproof.

 

Further reading here, here and here.

Documentation for the replace() here

Documentation for the replaceAll() here

 

Problem while installing Icegenerator on CentOS 6.5

By following this tutorial, one can easily setup a streaming audio server with icecast 2.3.3.

For me everything went well, until I tried to install icegenerator, which is the MP3 streaming client.

While trying to execute the ./configure command, libshout could not be located, causing the configuration to fail.

After some failed attempts along with some failed google searches, I found out the way to force-feed libshout's location by myself.

So, instead of just executing "./configure", try to execute:

./configure --with-shout=/opt/icecast/latest

I hope this does the trick for you as well, if you are stuck scratching your head a rainy Sunday morning...

Mini Git Tip

If you have done work and you have commited locally to your repository, only to find that what you have done is rubbish and irrelevant (it hurts, but it happens sometimes) and you want to synchronise to the remote, read on.

First of all, please, do not delete all your local files and then reclone the repository.

You may think I am exaggerating, but I've seen many developers do it.

Instead, use this command:

git reset --hard origin/master

to move back to where the remote origin currently is.


Or, if you are being picky about it, by using the following command:

git reset --hard <sha1-hash-goes-here>

you can reset your head to wherever you want to be.


If only this very last function existed in real life as well, that would be nice...


Wordpress Stuck in Maintenance Mode

If you find yourself locked out of your wordpress powered blog/site after executing an upgrade of some sort, do not panic.

While upgrading, wordpress creates a temporary file called .maintenance in the root folder of you blog.

This file is hidden, so you may have to set your FTP client to show hidden files, or perform an ls -a instead of a simple ls in order to see it.

The only thing you have to do is to delete this file and then login again and check the status of everything.

Hope this helps.

Wednesday the Sky

Don't save your wings for the summer...

Give up your fear and let it go...

Sixth of April - Six Years

Six years have passed since I chose a certain path in my life for the better or for the worst.

Passion, a lot of passion.

Fights, numerous fights.

Hate, a bit of that too.

But also love. More than everything else.

Circumstances has changed dramatically through the years, but it seems that we adapted in every one of them, probably we can adapt in new ones as well, sooner or later.

Love you.

More Feeds

Microfeed is proudly powered by Microfeed. MicrofeedCeption.