Setting up an environment

So, in order to have a vanilla environment where I’ll get to play around and have to configure most of the stuff myself (in order to force myself to learn), I decided to install CentOS 7 in a virtual machine. This will give the added benefit of keeping snapshots so that in case I get locked out of the linux box, I’ll be able to just revert to a previous snapshot. Of course, I could use a filesystem that supports snapshots itself, however I don’t want to. 😛 That’s something that I would like to learn on the distant future, so, point and click snapshots for the time being.

Continue Reading

New Year’s Resolution v0.16

Screenshot of a terminal with tmux running Midnight Commander, vim and htop

Shame on me.

It’s been almost four years without writing a single word in this blog. You can’t – of course – force creativity, but it’s not like I’d write long essays anyway. I do however like the technical side of things and I enjoy challenges in unhealthy amounts, if the enjoyment could be measured, that is.

So, my New Year’s resolution for 2016 is to blog. Not blog as in “sharing my thoughts”, but as in “document my path to the command-line mastering”. Because, yeah, I’ve been putting off learning a shitload of stuff that I want to learn. Did I fail to mention that above?

Continue Reading

How to check if a shortcode is registered in WordPress

Quick and easy function to check if a plugin/theme/whatever has add/registered a shortcode in WordPress:

function is_shortcode_defined($shortcode)
	global $shortcode_tags;
		return TRUE;
		return FALSE;

Just add this into your plugin or theme’s functions.php and wherever you need to check if the shortcode exists, just call is_shortcode_defined(“button”);  or something similar from an if statement, as such:

if( ! is_shortcode_defined("button") )
	add_shortcode("button", "my_button_function");

Hope this helps.

Continue Reading

Free Open Source Exchange Rates for PHP

Inspired by the Open Source Exchange Rates and money.js, I’ve developed a PHP class that consumes the service. Since the service fetches the exchange rates from the (unofficial) Google Calculator API, I played around with it as well, and found some differences on the exchange rates provided by the two services. It is probably that some caching is involved with (it updates every hour), but still, the rates are different, and for some applications more up-to-date rates may be necessary.

So I made both available for use with the class. You only need to instantiate the class passing the appropriate parameter on the constructor, and you are ready to start converting.

Continue Reading

Integrating CodeIgniter and MagpieRSS

So you want to use MagpieRSS from within CodeIgniter, so that you can fetch some feeds and do naughty stuff with them. No problemo. You download Magpie and you find that there are a few required files that depend on each other, and have an extension of .inc instead of the more common .php. Renaming the files will be a hassle, since you must find/replace all instances within the source code, and that will be a nuisance in case you later need to update your version of Magpie.

Continue Reading

mb_strtok() – A PHP implementation

While developing a web app, I needed to use the php’s multibyte family of functions. Having to deal with Greek characters specifically (although I always use utf-8) I needed the multibyte equivalent of strtok() to tokenize a stream of Greek characters. A quick look in the php documentation yielded almost every other function, but nothing relevant with what I need, so I decided to create my own version. I’m sharing it with you guys, as Google won’t help you either.

Continue Reading