a bunch of tips and tricks

Make a bash-script change directory to where it is located!

In case you have files that are located in the same directory as the script that are read by the script, and you are to lazy to make it a configuration variable 🙂

SCRIPT=$(readlink -f $0)
SCRIPTPATH=`dirname $SCRIPT`
cd $SCRIPTPATH

Make your Raspberry Pi Netboot over NFS

When I started using my first Raspberry Pi, I read about people having to change their SD-card every now and then because most (especially cheap) SD-cards are not made for being used as a harddisk replacement. So I googled a bit and setup NFS boot for my Raspberry Pi. Tested on Raspberry Pi Model B, B+ and 2.

This is what your cmdline.txt should look like, of course change the necessary information to correspond with your own environment.

ip=dhcp netboot=nfs boot=NFS=172.16.1.2:/Users/siho/openelec/system disk=NFS=172.16.1.2:/Users/siho/openelec/storage ssh quiet fastboot

…and of course you need to have a working NFS server with corresponding exports…

This is my /etc/exports

/Users/siho/openelec/system 
/Users/siho/openelec/storage -mapall=siho:staff

And yes, for observant readers, this is run on an OS X machine, but should work with any other BSD or Linux-system as well 🙂

Fix WordPress Menu Crash

Ever had a WordPress site with a huge amount of items in the Menu? Well I have (not this one), and after adding a menu item one day, the whole menu crashed, and with crashing I mean, it was written out as plain text over the whole page instead of being a neat menu in the header.

So, after some searching online, if found a bunch of people all complaining about this, some even suggesting you should buy a “mega menu plugin” to solve the problem.

Well actually, the problem is not in the WordPress or in the theme. Well, one might argue that it’s the way WordPress saves the menu, while it’s being edited that’s actually the problem, but never the less the problem is actually that there are limitations in PHP for how many input variables you are allowed to post in one transaction, so just login to your webserver, and edit your php.ini.

In my case I edited /etc/php5/apache2/php.ini and added the following on the end of the file:

; WordPress Edit Menu Fix
max_input_vars = 5000

Upgrade an Unsupported Ubuntu Linux to the latest version

If you like me stumble upon a machine running a version of Ubuntu that has become depreciated (End of Life), then fear not!

Fixing your broken sources.list

 

The first way I’ve noticed that something was wrong, was when I ran “apt-get update” and got a bunch of “404”‘s from our update server. But after some searching on the web I found that you can just replace the “archive.ubuntu.com” to “old-releases.ubuntu.com” in your /etc/apt/sources.list and use Ubuntu:s archive server to update your machine to the “latest and greatest” for your release.

sudo sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
sudo apt-get update && sudo apt-get dist-upgrade

You should now have a system that is as much up to date as possible, please consider doing a release upgrade now so you can continue to receive updates and security patches!

To upgrade to a new release:

Once you have performed the above steps to switch to the old-releases mirrors, update the Update Manager and then do do-release-upgrade:

sudo apt-get update
sudo apt-get install update-manager-core
sudo do-release-upgrade

Source: http://askubuntu.com/questions/91815/how-to-install-software-or-upgrade-from-an-old-unsupported-release

What is this place?

I used to have a domain called “hacktheplanet.eu” where I collected useful tips and tricks for my every day needs, I kind of miss that place so here we go again, it’s time for a new page with my every day useful tips to make my own life easier!