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.

Greek Online Banking

I tend to moan and bitch about the British online banking systems, but today I actually remembered that Greek people are in a far worse position than me.

At least with my HSBC account I can send money without commision to all major British banks, usually instantly.

The only thing that annoys me a bit is my secure key (a little device that gives you a one time password after you enter your pin to access you e-banking).

Well today, I had to transfer money from a Greek bank account of mine to another one and I had to pay commision 50 cents. It is not a big amount, but still, they have no right to make money this way in 2014.

First hit.

I had to find my Greek number sim card in order to receive an "extraPin".

I wonder what happens if somebody loses his phone. First of all it is not secure (somebody can transfer all your money and if he knows how to do it properly with a chain of transactions, the money will be dispersed in various bank accounts, one in Gibraltar, the other one in Canary Islands etc).

But odds are that nothing of the above will happen. I will probably have to travel to Greece, enter a store, waste the time of an employee explaining the situation etc. The bank is wasting its resources and I am wasting my time.

Second hit.

I had to find a way to convert an account number of another bank to an IBAN format. Some may say that this is not a tragedy since calculating an IBAN is easy if you know the account number and the bank.

And I will answer to them, well, if it is not a tragedy, why isn't the bank making this job for you? You lend them your money, they have to provide you with these types of services and make your life a bit easier.

The worst of all is the fact that they would charge me 9 euros if I don't calculate the IBAN.

Now, ladies and gentlemen, I call this a proper white collar theft. They are stealing money from the people that don't have the knowledge and the means to calculate something that THE BANKS invented in order to make transactions easier and safer between different banks.

Third hit.

After the transaction was complete, the final straw has been pulled out for me. I remembered that in 2014, Greek banks, will not transfer the money until Monday morning. And today is Friday night.

There is no way somebody can find an excuse for this in 2014, sorry.

This was the fourth and last hit.

I don't want to imagine having to run a business that transactions happen ofter in Greece. I just don't.

Exclude Subdirectory of Protected Apache Directory

So, you want to protect a couple of directories on your webserver for a handful of reasons, and you successfully did so, with .htaccess files.

But then you discovered that you want a subdirectory inside a protected directory to be public, again for a handful of reasons.

There is a small trick to quickly do that.

Just create a .htaccess file in the subdirectory you want to open to the public, and type in "Satisfy any" - without the quotes.

So, there you have it.

Once again, don't consider apache protected directories a real protection, they only exist for convenience reasons and to keep bots out.

They are very vulnerable to man-in-the-middle attacks.

London Road Surfacing

These days, Ealing Council is resurfacing the road in front of my house.

I was amazed at how quick and efficient the contractors were in performing the task, despite the extreme Health & Safety measures that probably get in the way (numerous notices, signs, regulations).

Probably the main reason that I am so surprised is the other extreme that is usually happening in Greece:

NO Health & Safety measures and extreme inneficiency.

I will try to shoot a video tomorrow with some footage for you to see...

Apache .htaccess related errors

If you are using .htaccess files in order to password protect directories on your server, you may have a bit of a headache setting it up, due to a few configuration details that people tend to forget.

Generally apache has a very straightforward procedure in order to setup and maintain a HTTP server, but it also has many features causing some details to end up hidden within the huge manual files.

Like the following one:

In order to setup password protection with .htaccess files, the first thing you have to do is to set up properly Allow Override in the main config file.

Other than that, be sure that the directory where the .htpasswd file is located, is executable by everyone - (rwxr-xr-x or 755) is what mine looks like.

Always remember, that if apache is giving you a hard time, the first thing you should do, is to take a look at the /var/log/apache/error_log before hitting your head against the wall and start changing conf files.

The last one is also a NOTE-TO-SELF.

Handmade Burgers

My beloved was in Birmingham for a couple of days and she dined in a place called "handmade burger".

She is difficult with food, but she was really pleased with everything. When she was back in London, she proposed that we go there, in order for me to try it out.

From a visit to the restaurant's website, I found out that the only London branch is located in Wembley, in the Designer Outlet Shopping Centre.

Luckily, I live in West London and Wembley is not that far, so we went there for lunch.

I chose a classic burger with cheddar cheese and thick English bacon. The meat of the burger was from Jimmy's Farm.

I have to admit that it was the best burger I had in my life so far. Accompanied with chips, various dips and a house salad dressed with a balsamic vinegar based dressing, it was a very nice meal.

They also do a killer Oreo milkshake and we had it for dessert.

I am looking forward to dine there again, give it a try!

Asylum

In your asylum
Inside your shell
A pearl slowly forming
But noone can tell
If in the darkness
It sparkles and shines
And there's no way of knowing
If it's all lies

I can't explain but there's something
Unnatural in the way
That you cry
As love turns to hate
Love turns to hate

MongoDB Integer Force-Feeding

When using the terminal interface to query a collection within a database in MongoDB, you will find it amusing that all numbers are treated as doubles by default, at least in newer versions.

There is nothing really wrong with that, but if you wrote your code when this was not the default setting, you are in need of a way to force-feed MongoDB an integer.

Well, it is not that difficult in the end. Just use the

NumberInt(117) function,
where instead of 117 you pass your desired integer.

Cheers!

Zero Carbohydrates and Salt Detox

The time has come. After overdoing it for several weeks (or months maybe), I am full of toxins and I tend to feel like crap. Something has to be done about this.

This week is going to be really challenging and hard for me:

- no carbohydrates
- no salt
- no sugar
- no...

Actually, it is a lot quicker to say what is included in the diet instead of what is not.

This is:

- egg white
- chicken fillet
- salad
- fruit
- tea

I will try to write down updates on my progress as well.

Massive Attack Radio Up and Running

Today I remembered a nice band called Massive Attack. I have completely forgot about them the last year.

This is why I made a radio for them. Check it out here.

Enjoy!

Thessaloniki

This is the first time in a long time that I actually miss my hometown and I feel homesick in general.

My friend Julia today posted the video below, and I saw all the places I used to go alone to get inspired, or walk with good friends and beloved ones to make some memories.

Now that I have been in a handful of European cities, I have to state that Thessaloniki is one of the best cities to live in, being unique and having a very distinctful character.

"When you live far away from a place, you tend to remember the good parts of it and put aside the bad ones"

I remember that when I was about to leave Thessaloniki behind, I was relieved, because in my mind, it represented the problems I had living there. The fact that I "changed glasses" means that I solved most of these problems here in London.

Let's put it this way:

When there is a lot of passion in a relationship, there is no stability. Love can quickly turn to hate because lust is in the way.

Thessaloniki is this kind of woman. London on the other hand, is the woman that can adapt to your needs and give you what you want to make you happy, but it is lacking this passion.

This is how it feels for me, I would fancy a small visit sometime soon.

Enjoy!

More Feeds

Microfeed is proudly powered by Microfeed. MicrofeedCeption.