In case you need to get the post/page/{$custom_type} ID from a WordPress content, from a remote site or no direct access to the database, here’s an easy and reliable way to do it.
Tag: programming
Goodbye controllers, hello request handlers
Request handlers are a different, simpler way to structure a PHP app leveraging the __invoke()
magic method to create truly single-responsibility classes.
Does javascript guarantee object property order?
Does Javascript guarantee object property order? No. Or… actually, not always
Can complexity emerge from lower levels of simplicity?
‘Is there really a Universe that is not designed from the top downwards but from the bottom upwards? Can complexity emerge from lower levels of simplicity?’ It has always struck me as being bizarre that the idea of God as a creator was considered sufficient explanation for the complexity we see around us, because it… Continue reading Can complexity emerge from lower levels of simplicity?
Jared Friedman from Scribd explains why he wouldn’t use Rails for a new company.
His main reasons are:
- Ruby is slow — yup, even PHP with HHVM it’s faster
- Rails is static while others have caught up
- There are better new alternatives
What is code? It’s not magic, just work
It’s very likely that you already know about or even read the latest issue of Bloomberg, entirely dedicated to answer What is Code? — if you haven’t, you definitely should go read it. The entire piece is informative and fun to read, and there’s probably something new for everyone reading it. My favourite highlight is:… Continue reading What is code? It’s not magic, just work
One of the most common worries of the enterprise IT world about WordPress and other Open Source apps it’s how you can scale it — which it’s kind of ironic when their enterprise-y web services response times are usually measured in the scale of tens of seconds…
DigitalOcean has published a high-level practical-overview on horizontally scaling PHP apps that’s a good starting point and I guess it could also apply to other kinds of apps as well.
Debugging memory usage in PHP apps
As your app gets increasingly more complex, you might run into Memory exhausted errors, and even though you can always increase the allowed memory usage — either by tweaking php.ini or locally with ini_set() — it should be a better option to find out what’s using so much memory in the first place.
Simple, humble and effective. Whenever you’re reviewing old code, or other people’s code, apply one simple rule:
Leave it better than you found it
Using anonymous functions and closures for user-defined array sorting
Anonymous functions and closures are relatively new in PHP, but they’re extremely welcome. Whenever you need to sort an array with a custom order (that is, with a user-defined comparison function such as usort, uasort or uksort) you can use anonymous functions and closures in an easy and very straight-forward way. For instance: