Sunday, March 31, 2013

How to change file upload size in phpmyadmin!

For lesser mortals in the universe of databases, who still inadvertently use lot of MySql, a tool like PHPMyadmin is the holy grail!

This web browser based, php querier accesses MySql tables and also gives tremendous functionalities to tinker with the databases. While most of it is intuitive, sometimes a small feature requirement needs the options beyond the defaults.

Before I delve into these non-default configurations, just for the record, here is how you get your phpmyadmin to access your mysql tables on your Debian based machines.

fsmk@gnu:~$ sudo apt-get install phpmyadmin

Once, you have installed, as a dependency Apache also gets installed. To access phpmyadmin, open your favourite web browser and type on "http://localhost/phpmyadmin"

Now, that settled let me get into the issue of the post.
SQL backup, taken from different servers or simply for the purpose of backing up data are the most precious files on my computer, at least. Now, to move in and out of different machines with the mysql data, phpmyadmin offers a cool import/export option.

While export is flawless, import has a default option which restricts the maximum file upload size to 2M. Once you encounter sql's which are more than 2M you know you are handling quite a lot of data, and in such cases how to restore these >2M files?

The configuration file for the phpmyadmin which checks this option is a php.ini file, which resides in the /etc/php5/apache2/ directory.



Get hold of this file, and search for "upload_max_filesize" in the php.ini file. After you've got it change it to whatever that your maximum file size might be.
Restart your apache service to upload those massive sqls into your database.

Sunday, March 17, 2013

Embeding long tables in plain HTML, using Libre Office

When using plain HTML for design of web pages, and there aren't any WYSIWG editors, and there is an inevitable requirement to embed tables into the HTML file, the <table> tag is quite handy.

<table border="1">
<tr>
<td><b>Movie</b></td>
<td><b>Favourite character</b></td>
</tr>
<tr>
<td>The Matrix</td>
<td>Neo</td>
</tr>
<tr>
<td>The Lord of the Ring</td>
<td>Eragon</td>
</tr>
<tr>
<td>V for Vendetta</td>
<td>Ivy</td>
</tr>
</table>

Will result in


For a table with couple of entries and default options, this syntax follows, and is adequate.

But, when one has to embed a longer table, with many more rows and columns and don't ask me why! Just in case, you find yourself in such a state that you have a complete table existing already in your document or spreadsheet and you do not have the patience or the in-aptitude to type out all of it using the syntax shown above, Libre Office (or even Open Office) comes to rescue!

Copy the entire table that you want to embed in a HTML file, and paste it into a new HTML document that you can create from the Libre Office prompt. Once you are done formatting your new table in a Libre Office HTML file, save it as a .html file.



All you now have to do is, locate the new .html file you created using Libre Office and open it with your favourite text editor!

It is a HTML file now with all the taggings done for your table, which otherwise would have taken painstaking hours of labour to reach that form! Copy-Paste the HTML code into your webpage that you started off wanting to embed a table.
It's ready!

Libre, set me literally free this time!

Happy hacking!
PS: Of course there might be better methods to accomplish this, if you do have one please post it as a comment :) 

Tuesday, March 12, 2013

Find,replace in multiple files using BASH

Another of those zillions of tweaks that I am afraid will slip out of my head! So jotting it down here.

When you are editing HTML files, or some similar content template with multiple changes to be done in a huge number of files, it is simply excruciating to dig into each of the files and search for a pattern and change it.

For instance, if you have a host of html files, and you need to maybe make one common change in all files, the simplest thing to do is use the power of BASH!

To change a string, recursively in multiple files, use the following command.

raghav@fossphosis:~$grep -rl 'old-string' ./ | xargs sed -i 's/old-string/new-string/g'

'grep' as always performs pattern matching
'sed' is used as the stream editor

Old-string is the string to be changed, into new-string.

May the power of BASH be yours!
GNU Rocks.