Random PHP function

To explore new things, I sometimes use the ‘Random article‘ link on Wikipedia. It is a simple and basic principle, but it gets you to articles you would never get by just browsing the site.

I was looking for something that did the same job for the php.net site, but could not find anything. As a programmer, you’re most likely to end up in the same chapters of the manual over and over again, and a ‘Random function’ link would be nice to find out new stuff.

So I wrote on myself…

The script parses the http://php.net/quickref.php page, and picks a random link to redirect you to. Anyone heard of HaruDoc? 🙂

Try it yourself: Random PHP Function. Good luck!

Stuff to read from Google

Google

Google has some really nice stuff to read, written in an easy to read way, about all sorts of things. It’s a lot about front-end things, but as a back-end developer I’m responsible to build pages & sites with an infrastructure which leverages these things.

The things I found recently:

ini_restore() and str_replace()

Today I’ve found a new function (new for me, that is). The function is called ini_restore(). It’s a small and simple function call, but it’s just cool to use built-in functions and save some typing and variables.

I use ini_set() from time to time in large scripts where I know it will take a while to execute and need some additional resources. I always try to avoid to set resets on the top of the script, because most of the scripts is doing regular stuff. When it would go wrong there, I want to know about it.

This is where ini_restore() comes in to play:

// old
$origMaxExecutionTime = ini_get('max_execution_time');
ini_set('max_execution_time', 900); // 15 minutes
// do some amazingly long work
ini_set('max_execution_time', $origMaxExecutionTime);

// new
ini_set('max_execution_time', 900); // 15 minutes
// do some amazingly long work
ini_restore('max_execution_time');

Aside from that one, I’ve discovered the fourth parameter in str_replace(): &$count. Nice to know whether the function call did anything or not.

Next step is to beat that annoying multibyte thing in str_replace().

My personal home server – part 2

dyndns

In the previous post I was terribly wrong about the router type. I was talking about a Linksys (by Cisco). My brother hooked me up with an ‘old’ WRT54GL he had laying in the basement.

The cool thing about these routers is that they have built-in DynDNS support. (If you don’t know what it is, Wikipedia has a good article about it). What it basically does is pointing a host name to a dynamic IP address. ISP’s don’t like this, but you’re doing nothing wrong with it.

With the router in place, my network is secured and I’ve added some port forwards to my Centos server.

I’ve added some accounts for some of my friends and opened SSH for them through the internet. Succes!

My personal home server – part 1

centos_logo

A month ago I moved to my new house (yay) and I’d promised Joggink I would set up a home server we could use to play with.

Several weeks later, I’ve managed (as in: finally had time, rather than: it was complex) to do a complete install of CentOS on our ‘server’.

No I’m waiting on my router (some D-Link, I forgot the type) to complete the access to the internet and make sure it’s secure!

Bear with me 😉

I am officially online

PING blog.jachim.be (82.146.116.150): 56 data bytes
64 bytes from 82.146.116.150: icmp_seq=0 ttl=55 time=11.934 ms
64 bytes from 82.146.116.150: icmp_seq=1 ttl=55 time=12.418 ms
64 bytes from 82.146.116.150: icmp_seq=2 ttl=55 time=12.381 ms
64 bytes from 82.146.116.150: icmp_seq=3 ttl=55 time=11.878 ms
64 bytes from 82.146.116.150: icmp_seq=4 ttl=55 time=12.324 ms

--- blog.jachim.be ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 11.878/12.187/12.418/0.232 ms