Simple interface for viewing the PHP error log file


Example usage

Recently at work I found myself trawling through the PHP error log file and found that all the lines of text were starting to blur after a while. Thinking there had to be a better way over viewing the log file, and following on from my single-file opcache viewer gui, I decided to knock out something for viewing the error log file as well.

With this single-file error log gui it will only show the error once and then tell you how many times it appears in the log. It will allow you to narrow down your search of errors by being able to hide the different types or sort in different ways, and it will also allow you to search results based on particular file paths.

I’ve pushed the code up to my GitHub account, so please feel free to fork and improve and/or give feedback.

Did you like this? Share it:

Counters in CSS: making a table of contents list

As I’m sure you know, you can create an ordered bullet point list but it has limitations.  For example, if I wanted to have a table of contents so that the numbering goes 1, 1.1, 1.2, 1.2.1, 1.2.2, 1.2.3, 1.2.3.1 and so on then the standard ordered list just isn’t going to cut it.  Oh, sure, you could reset the numbering on the sub-lists so that it uses roman numerals or something like that but to me that just doesn’t feel quite right…

Enter CSS counters!

Counters offer you a way to increment and decrement a value every time an element has the rule, and there doesn’t have to be one counter – you can have as many as you need,

So using counters can easily produce the correct kind of TOC list that we want. And here’s the jsFiddle to show you just how easy it is.

Did you like this? Share it:

Tweeting on a button press with the Raspberry Pi


A while ago my door bell broke. So I did what any sensible person would; I decided that instead of buying a new one I would hook up an old bell I had to a Raspberry Pi and have the bell ring when someone pushed a button on my door. But then I though, “well, that’s a bit boring.  My doorbell should tweet me, too!”

The long and the short of it is that I couldn’t get the mechanics of the bell ringer to work but had a lot of fun with the tweeting side of things because it involved my first shot at doing some Python code.

This is roughly how I did it…

Continue reading

Did you like this? Share it:
simple-botting-with-php

Book review: Instant simple botting with PHP

I had the chance recently to read the book Instant Simple Botting with PHP, written by Shay Anderson and published by Packt Publishing. The book is designed to be a very quick and easy (hence the title!) introduction in to creating bots to scan web pages and collect information from them.

The book seems squarely aimed at beginners in PHP and object orientated programming so lives up quite well to the “simple” aspect of the title. However, I wouldn’t really say “instant” because there are quite a few pages dedicated to setting up PHP and making sure it works with a simple “Hello world”. My preference would have been just to assume that  someone that wants to know how to create bots probably already has PHP set up and has at least a passing familiarity with it. But as it seems to cater to real beginners I suppose it needs to hand-hold people through the setup.

The code is clear throughout and easy for anyone to understand and follow and by the end of it you’ll have something that will very basically scrape a web page. If you’re a beginner I’d imagine you’d be left with some sense of accomplishment and something pretty simple with which you should be able to tinker without getting too caught up with a tonne of code or complexity. However, if you are any kind of seasoned developer then you will probably find the book too light-weight as there are no advanced techniques are really discussed. But then, what would you expect with just around 60 pages in the book?

However, as I’ve said, the code is nice an clean, the book for what it is is well written, and the author discusses some good practices.  Great for a beginner but probably not enough for a mid/seasoned developer.

Did you like this? Share it:

Easy page scraping with Zend\Dom (from Zend Framework 2)


The other day I was interested in getting some information from the sussex.academia.edu site, specifically I wanted a list of tags for each of the faculty members. Now, this sounds relatively easy except when you consider that initial page contains a list of links to various schools/departments people have listed, and then under each of those pages you have different fieldsets with different types of people on them (and I was only interested in the faculty fieldset), and each person may or may not have tags and even then those tags may be hidden behind some javascript so that you click and view all of the tags… When you consider all of that you would be forgiven in thinking that it’s actually quite a daunting task!

Let me assure you, though, that by using Zend\Dom from the Zend Framework 2 library it’s actually a really simple task. In fact, I did it in around 20 lines of code.

So let’s start by looking at the code and then break it down a little more.

Continue reading

Did you like this? Share it:

Zend Studio and SVN 1.8

I use SVN for most of my projects at work and have diligently kept it up-to-date with the latest versions of the work copies. What happens when the working copy structure changes, as it did from 1.7.x to 1.8.x, is that Zend Studio gives error messages about the SVN connector client not being compatible. Annoying! However, if like me you’ve recently updated your SVN version to 1.8 and want Zend Studio to be compatible then it’s just a matter of a few easy steps for you to take.

Continue reading

Did you like this? Share it:

Same height for elements


A while ago I wrote a jquery plug-in that allows you to easily make selected elements all the same height. Well, it turns out that it could be a little better because it didn’t take in to consideration margins, padding and such. So here’s a slightly more robust version.

Did you like this? Share it:

Zend OPcache – some info and a GUI


I’ve just started to use Zend OPcache in place of APC in a few places and so far it’s great!

Because documentation seems a little scarce right now, I’ve decided to jot down the methods available (mainly so I don’t forget).

opcache_reset
Should be pretty obvious given the name – resets the opcache

opcache_get_configuration
This will return an array with three indices, one for the directives that have been set, one for version information and one for any blacklisted paths. For example:

Array
(
    [directives] => Array
        (
            [opcache.enable] => 1
            [opcache.enable_cli] => 1
            [opcache.use_cwd] => 1
            [opcache.validate_timestamps] => 1
            [opcache.inherited_hack] => 1
            [opcache.dups_fix] => 
            [opcache.revalidate_path] => 
            [opcache.log_verbosity_level] => 1
            [opcache.memory_consumption] => 134217728
            [opcache.max_accelerated_files] => 4000
            [opcache.max_wasted_percentage] => 0.05
            [opcache.consistency_checks] => 0
            [opcache.force_restart_timeout] => 180
            [opcache.revalidate_freq] => 2
            [opcache.preferred_memory_model] => 
            [opcache.blacklist_filename] => 
            [opcache.max_file_size] => 0
            [opcache.error_log] => 
            [opcache.protect_memory] => 
            [opcache.save_comments] => 1
            [opcache.load_comments] => 1
            [opcache.fast_shutdown] => 1
            [opcache.enable_file_override] => 
            [opcache.optimization_level] => 2147483647
        )

    [version] => Array
        (
            [version] => 7.0.2-dev
            [opcache_product_name] => Zend OPcache
        )

    [blacklist] => Array
        (
        )

)

opcache_get_status
This will return that holds information about whether the opcache is turned on or not, whether it’s in a restart phase, the memory usage and hit statistics, and any files that have been cached along with hit and memory details. For example:

Array
(
    [opcache_enabled] => 1
    [cache_full] => 
    [restart_pending] => 
    [restart_in_progress] => 
    [memory_usage] => Array
        (
            [used_memory] => 9395880
            [free_memory] => 121987104
            [wasted_memory] => 2834744
            [current_wasted_percentage] => 2.1120488643646
        )

    [opcache_statistics] => Array
        (
            [num_cached_scripts] => 353
            [num_cached_keys] => 1546
            [max_cached_keys] => 7963
            [hits] => 27055
            [start_time] => 1365412384
            [last_restart_time] => 0
            [oom_restarts] => 0
            [hash_restarts] => 0
            [manual_restarts] => 0
            [misses] => 509
            [blacklist_misses] => 0
            [blacklist_miss_ratio] => 0
            [opcache_hit_rate] => 98.153388477725
        )

    [scripts] => Array
        (
            [/http/includes/libs/ZF-1.12.2/Zend/Loader/Autoloader.php] => Array
                (
                    [full_path] => /http/libs/ZF-1.12.2/Zend/Loader/Autoloader.php
                    [hits] => 175
                    [memory_consumption] => 63320
                    [last_used] => Mon Apr  8 16:21:14 2013
                    [last_used_timestamp] => 1365434474
                    [timestamp] => 1343660895
                )

            [/http/www-includes/libs/ZF-1.12.2/Zend/Db/Adapter/Oracle.php] => Array
                (
                    [full_path] => /http/libs/ZF-1.12.2/Zend/Db/Adapter/Oracle.php
                    [hits] => 17
                    [memory_consumption] => 60600
                    [last_used] => Mon Apr  8 16:21:14 2013
                    [last_used_timestamp] => 1365434474
                    [timestamp] => 1325795702
                )

            [/http/libs/ZF-1.12.2/Zend/View/Helper/Placeholder/Container.php] => Array
                (
                    [full_path] => /http/libs/ZF-1.12.2/Zend/View/Helper/Placeholder/Container.php
                    [hits] => 175
                    [memory_consumption] => 2744
                    [last_used] => Mon Apr  8 16:21:14 2013
                    [last_used_timestamp] => 1365434474
                    [timestamp] => 1325795702
                )
                ...
        )

)

GUI

APC did have a GUI which was quite handy to see what had been cached, settings and memory usage but Zend OPcache doesn’t (currently as far as I could see) have anything similar.

It is possible to get information from looking at the output of phpinfo() which contains all of the key information.

However, I’ve just pushed the start of a GUI to GitHub. If you want to make changes and improvements then please feel free! It’s only had a very little amount of work done on it so far so is pretty raw.

Did you like this? Share it:

My CodeMagic fork (a TinyMCE plugin for code editing)


I’ve used TinyMCE for a while – it’s an excellent WYSIWYG editor for web applications. However, the code editor in it is really simplistic. Enter CodeMagic, a plugin that allows you to replace the standard code editor with one that used the excellent CodeMirror library for syntax highlighting. So I started to use CodeMagic but found a number of issues with it. For example, it used CodeMirror 2 and not 3, had issues with using IE and the word wrapping functionality and the window resizing was never great. But with the joy of things being on GitHub and up for a bit of a forking, that’s exactly what I did.

Check out my CodeMagic fork on GitHub and feel free to give me any feedback, or fork it yourself and make it better.

Did you like this? Share it: