noiselabs.org
yet another lighthouse for Linux geeks and code monkeys
yet another lighthouse for Linux geeks and code monkeys
Dec 4th
Hello all! I’ve released yesterday the first version of SmartyBundle on GitHub.
SmartyBundle is Symfony2 a bundle that provides integration for the Smarty3 template engine. It will allow the usage of the Smarty template engine in Symfony2, instead of Twig or PHP templates. SmartyBundle is released under a LPGLv3 license. To download it you may:
Git-clone-it:
$ git clone https://github.com/noiselabs/SmartyBundle.git
or download the repository as a zip file:
https://github.com/noiselabs/SmartyBundle/zipball/master
Full documentation is available on GitHub and after download in the Resources/doc/ folder.
Symfony is a Open Source PHP Web Development Framework. It is currently my PHP framework of choice that first grabbed my attention by its standalone components and got me back to PHP after digging into the, Python-based, TurboGears Web framework.
Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Version 3 brings some important improvements like the addition of template inheritance and a complete code rewrite to make use of new PHP5 capabilities.
I welcome everyone interested to try it, test it and to improve its code by sending comments, suggestions and GitHub pull requests. Bugs and feature requests are tracked on GitHub.
Thanks and see you soon
Apr 25th
After my last Xorg update I’ve lost the nice ability to log into my KDE. Well, this *sucks* because I spent a long time compiling kdelibs and friends so I really want to use it.
A blank screen on
If you take a look at the Xorg log you’ll see X is mad about a “batch buffer thingie”.
Error in /var/log/Xorg.0.log: (EE) intel(0): Failed to submit batch buffer, expect rendering corruption or even a frozen display: No such device
Pretty ease to solve this one. Either upgrade your kernel to something like 2.6.36 or better (recommended) or block xf86-video-intel>2.14.
Permanent solution
Upgrade your kernel. I was running an old 2.6.32-tuxonice-r7. Upgraded to 2.6.36 and… Welcome back, KDE.
# emerge --sync && emerge --update gentoo-sources
Workaround (if you’re in a hurry)
Add this to /etc/portage/package.mask
>=x11-drivers/xf86-video-intel-2.14.0
and recompile.
# emerge --update x11-drivers/xf86-video-intel
Apr 25th
While working with the TableTools PDF generator included in the great DataTables jQuery plugin I’ve noticed that sometimes the script failed to generate the PDF file. The cause? Invalid characters in the filename.
Well, to solve this issue I’ve made a simple PHP function to return a safe version of the given filename.
Reads a filename string and replace each “dangerous” character with an underscore. Of course you can use any other “safe” character instead of an underscore.
This snippet and other useful [at least, I hope so] PHP methods are grouped on a git repo available via GitHub. This is also the best [and only] way to get the updated version of the code.
Go to the project’s web page on GitHub or download it right way with (you must have Git installed first):
$ git clone git://github.com/noiselabs/noiselabs-php-toolkit.git
May 1st
Everyday morning was the same: updatedb came and took my Gentoo away. The symptoms were clear, X/KDE applications starting to become slow and unresponsive, and then the two inevitable choices: go for a coffee and wait or pkill the bastard.
To fix this came to my mind the nice command. This is well known to Gentoo users because of the PORTAGE_NICENESS feature include in make.conf. Nice is a program that adjusts the process scheduling (aka niceness) of the desired programs so setting a value of 19 (the maximum) would make updatedb to be “nicer” to other applications and therefore being less bossy. So I’ve edited /etc/cron.daily/slocate, placed “nice -n 19″ before the updatedb command and waited. But, once again, updatedb came and owned my computer.
So. what’s wrong here? Updatedb is not a CPU-intensive application so nice won’t change a thing. The bottleneck is disk access so what we need here is a nice for I/O. The solution? Ionice.
Ionice is able to set the I/O scheduling class and priority for a given program. To give updatedb a low priority we pick the class 3, the idle one.
Again, let’s go to crontab and edit the slocate entry.
# vim /etc/cron.daily/slocate
Put ionice -c 3 before the updatedb command.
#! /bin/sh
if [ -x /usr/bin/updatedb ]
then
if [ -f /etc/updatedb.conf ]
then
ionice -c 3 /usr/bin/updatedb
else
ionice -c 3 /usr/bin/updatedb -f proc
fi
fi
And if you’re asking where (in Gentoo) is this ionice program, the solution is sys-apps/util-linux, which I’m pretty sure is already installed. If not: emerge -a sys-apps/util-linux.
Updatedb is a tool ran daily by cron to update the slocate database. And Slocate (Secure Locate) is a security enhanced version of the GNU Locate, which is used to index all the files of your system allowing a (very) quick search of them. In Gentoo Linux the slocate is available in Portage through sys-apps/slocate.
Mar 14th
No, this will not replace Google Translate or Babel Fish. But it does something that these tools simply can’t offer.
For some time I’ve been using Wikipedia to translate expressions that a normal translator couldn’t give exact results, because they use literal translations. Now there is a faster way.
MemeMiner, brought to us by Fred Rocha, is a Web tool that does this work and gives us a easy and fast way to get this translations.
From the author own words:
For most of it’s articles, Wikipedia provides the equivalent expression of that concept in other languages.
With MemeMiner you can effortlessly find out how a certain idea is expressed across the language spectrum.
Now go ahead and try this tool at http://fredrocha.net/MemeMiner/
Thanks Fred!
Feb 27th
I was doing the usual make dist process to launch a tarball for one of my apps when tar died with the following message:
tar: file name is too long (max 99); not dumped tar: Error exit delayed from previous errors
If you happen to see the same error message it is quite likely that you (and by you I mean Automake)Â are using the old V7 tar format.
Just want the solution? It’s here
By default Automake is pulling the historical V7 format to generate the tarball with make dist. This tar format supports file names only up to 99 characters and that’s why tar is refusing to build the tarball.
Since automake 1.9, th tar format can be chosen with the options tar-v7, tar-ustar, and tar-pax.
This is what the Automake manual says about each option:
This is the historical default. This antiquated format is understood by all tar implementations and supports file names with up to 99 characters. When given longer file names some tar implementations will diagnose the problem while other will generate broken tarballs or use non-portable extensions. Furthermore, the V7 format cannot store empty directories.
(…) format defined by POSIX 1003.1-1988. This format is believed to be old enough to be portable. It fully supports empty directories. It can store file names with up to 256 characters, provided that the file name can be split at directory separator in two parts, first of them being at most 155 bytes long. So, in most cases the maximum file name length will be shorter than 256 characters. However you may run against broken tar implementations that incorrectly handle file names longer than 99 characters.
(…) the new pax interchange format defined by POSIX 1003.1-2001. It does not limit the length of file names. However, this format is very young and should probably be restricted to packages that target only very modern platforms. There are moves to change the pax format in an upward-compatible way, so this option may refer to a more recent version in the future.
The solution is to pick a newer and better tar implementation like tar-pax. Go to configure.ac or configure.in and change the AM_INIT_AUTOMAKE macro so it specifies the tar format and requires automake version to be 1.9 or better as tar-pax is only supported since 1.9.
configure.ac/configure.in:
AM_INIT_AUTOMAKE([1.9 tar-pax])
Now run `make dist` again and tar won’t bother you anymore (at least with this error
).
Feb 22nd
This are good news for the Gentoo community. Portage is being used to build Chromium OS packages. As you may know Portage is the Gentoo Linux default package management system which has its roots on FreeBSD’s ports.
As of February 5, Google developer Ryan Cairns has made this statement on the Chromium OS dev mailing list:
As we’ve been growing and working with more partners, the need to support board specific builds and improve our tools has become more urgent. In order to get there more quickly we’ve been investigating several different build tools. We found that the Portage build tools suit our needs well and we will be transitioning 100% within the next week.
As a Gentoo user and supporter I’m happy to see Portage being picked by major projects like the Chromium OS. Hopefully it will bring more (positive) attention to Gentoo and maybe we will see the Google folks contributing with improvements and bug fixes back to Portage.
For those interested in checking out the Portage-based build environment and build a bootable Chromium OS image take a look at this Chromium OS documentation page.
If you are interested in Portage features and usage check the Gentoo Handbook page about Portage. And if you got curious about Portage history I recommend the this article by Daniel Robbins, the founder of Gentoo.
To know more about the Chromium OS project and Google Chrome OS check this.
Feb 21st
Want to get rid of all those unread messages in Gmail? Or, just like me, have some unread messages you can’t find and want to reset the unread count to zero? Well, here is the solution:

Type "is:unread" in the search bar and then select "Unread" from the selection bar

In the "More actions" dropdown select "Mark as read"
And that’s it. Your inbox shouldn’t be reporting any unread messages by now.
Feb 18th
This is a simple way to check a UTF-8 string with PHP function preg_match in search for anything that isn’t a letter, which includes all UTF-8 letters and not just ASCII. Preg_match performs a regular match on the given input using a pattern. The pattern used tells preg_match to look for letters (\p{L}) using Unicode (/u).
The function to accomplish this could look like this:
function checkUTF8Input($input)
{
$pattern = '/^[\p{L} ]+$/u';
preg_match($pattern, $string, $matches);
if (count($matches) > 0)
return true; // String is OK (only letters)
else
return false; // String has non-utf8 letters
}
Take a look at preg_match to know more about this function used for regex operations.