Archive for category Programming
📅 April 26, 2017
What if we want to grab an integer, say, from 1 to 25 inclusive?
We can do this easily by modifying the random result to our liking.
📅 September 24, 2016
In PHP, we can use php_uname to grab information about the operating system that the server is running on.
echo php_uname(‘s’) will give the name of the OS, but this is a general name. When executed from a server running Xubuntu, it returns the string “Linux.” Is this Ubuntu, Kubuntu, Xubuntu, Linux Mint, or…what?
What if we want to get the specific Linux distribution? Is this possible from PHP without performing host OS system calls or executing Bash scripts? Yes.
📅 February 4, 2016
Using a similar technique as the random text PHP code, here is a simple code snippet that chooses an image file at random and displays it in a browser.
By moving the code to the server side, a random banner image (or any kind of image) will appear in order to add freshness to a page.
📅 February 3, 2016
Here is a simple but fun PHP code snippet that displays one of several text strings chosen at random to add an element of surprise to a page.
First of all, a working PHP server is required in order to process PHP scripts. This could be a virtual machine using VirtualBox, for example, or something else on any platform. This short tutorial assumes that you have one set up and working.
For example, if there are 3 duplicate items in a list of 10, then there is a 3x probability of obtaining that particular item compared to a single occurrence of that item in the list.
The idea is that by eliminating the duplicates, all items should have an equal chance of being chosen. Here is one strategy to achieve this using a set.
SweetFX Levels sets new black and white points. This means every pixel whose value is below the black point will be converted into pure black, and every pixel whose value is above the white point will be converted into pure white.
Think of this as the equivalent of level adjustment in GIMP using the histogram. Used sparingly, Levels will trim off excess whiteness, and it will darken shadows and other dark areas that appear too “washed out” when they should be darker.
On the other hand, visual detail is lost when used excessively, and drastic scene changes can be produced. This is either good or bad depending upon the desired effect. In short, Levels is an effect best used for minor touchups to the resulting image.
SweetFX Vignette darkens the corners of the image to produce a peephole or faded corner effect. This can be used with other effects, such as Sepia and Monochrome, to produce a variation of the old-time photo effect.
Of course, Vignette settings can darken an area greater than the corners alone until the entire image is obscured, so use sparingly for the best results.