Sylwester Wojnowski

code for the web

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, are easy to use and free for whatever project you may need them. If you've dealt with a standard WordPress theme like twentyfifteen recently you probably noticed, those themes rely upon ...

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