Sylwester Wojnowski

code for the web

installing PHPUnit

Created:18 Feb 2017 15:10:51

installing PHPUnit

If you are any serious about writing code in PHP computer language you have tried some unit testing frameworks by now. Some of them are better than others, one that really stands out, both in terms of code quality and documentation is Sebastian's Bergmann PHPUnit. ...

Read more

Arrays in BASH

Created:12 Feb 2017 14:48:27

Arrays in BASH

Once one is somewhat familiar with basic number and string variable handling rules in BASH, a need for a container to store and manipulate theme quickly arises. BASH provides such a convenient container in the form of array. This article is about zero-based and number indexed ...

Read more

BASH recursion examples - part 2

Created:30 Jan 2017 17:08:29

BASH recursion examples - part 2

This article is a follow-up on the subject of writing recursive code in BASH. In the first part of the series I focused on a few more popular Maths functions and how one could implement them in BASH. In this instalment focus shifts to tasks one often comes across whilst ...

Read more

Essential WordPress plugin hooks

Created:17 Jan 2017 11:57:41

Essential WordPress plugin hooks

In this article I look at some essential WordPress hooks. By 'essential hooks' I mean actions and filters you use frequently when writing a WordPress plugin. Sometimes in the context of this article 'essential hook' refers to a hook you cannot do without to ...

Read more

Bash recursion examples - part 1

Created:15 Jan 2017 16:58:45

Bash recursion examples - part 1

Recursion in computer science is a technique based on two cases. One is non-recursive terminating case, the other, recursive. The former finds you the final solution, the latter reduces problem to the termination case. This is I guess the most important bit, one should ...

Read more

Env and BASH declare

Created:11 Jan 2017 12:58:48

Env and BASH declare

Environmental variables on a Linux based system like Debian are named strings available to all applications initialized from text console or some graphical interface. These variables are gradually added by various processes as your system starts. Once login shell is invoked ...

Read more

Updating WordPress database URLs - part 2

Created:03 Jan 2017 13:03:49

Updating WordPress database URLs - part 2

In this second part on the updating WordPress database URLs I'll concentrate on a database-wide approach. All tables will be scanned and old URLs updated to new ones. Also serialized data will be properly dealt with. In this part, mysql utility will not be involved ( but ...

Read more

Updating WordPress database URLs - part 1

Created:01 Jan 2017 15:27:35

Updating WordPress database URLs - part 1

Either when developing a new WordPress website or when dealing with one that already exists but is in need of a move to another host, you're certain to come across an issue related to updating old domain name with a new one. A typical WordPress website ( by typical I ...

Read more

Find first image URL in WordPress post content

Created:29 Dec 2016 06:59:28

Find first image URL in WordPress post content

With ever growing importance of websites like Pinterest, and in particular due to their reliance on images, and for general post linking purposes often it is desirable or even necessary to be able to find at least one image in your WordPress blog entry automatically and in an ...

Read more

Genericons unicode values

Created:21 Dec 2016 11:07:56

Genericons unicode values

Genericons is a set of vector icons embedded in a webfont. They look crisp, scale well and are easy to use. Moreover they are also free to use for whatever project you may need them. If you've dealt with a standard WordPress theme like twentyfifteen you probably noticed, ...

Read more

Sorting objects by their property in PHP

Created:10 Dec 2016 13:10:14

Sorting objects by their property in PHP

Lets say you have got an array of assorted objects, each with the same set of properties, which are either numbers or strings, and you would like to sort them by one of those properties using PHP. Since it is a fairly common requirement, you can expect the basic tools are ...

Read more

Setting home and siteurl dynamically in Wordpress

Created:10 Dec 2016 09:44:06

Setting home and siteurl dynamically in Wordpress

If for some reason you have set siteurl and / or home options wrong in your WordPress installation database and as a result can't access admin panel, or perhaps have a reason not to change these options in wp_options table, you can overwrite them either in wp_config.php or ...

Read more

The most used Wordpress hooks

Created:28 Nov 2016 20:53:05

The most used Wordpress hooks

Below is a list of the most often used hooks (sorted by the number of callbacks attached ) on a vanilla installation of WordPress (v.4.6.1) with twentysixteen theme loaded. On such a setup, in total I found 261 hooks, something was attached to. As seen in the list, the most ...

Read more

Find total of a column of numbers with BASH

Created:28 Nov 2016 20:53:05

Find total of a column of numbers with BASH

Suppose you have a file with a long list of items followed or perhaps preceded by whole numbers and you are asked to find the total of those numbers. The file might look like this (case 1): aaa:23 bb:2 ccc:98 . . . or perhaps like this (case ...

Read more