Author: Gugu Ncube
-
MySQL – Sorting records/users based on closeness to a age in SQL
Use: sort by users whose age is closest to a defined age. In the example below, 25 years. User Age 1 25 3 23 4 26 5 27 Idea: select abs(u_age-25) as age_difference, u_age from users order by age_difference, u_age; The MySQL function abs ensures that the subtracted result is always positive. The date of…
-
PHP – Simple Function for URL Redirection
Redirecting to another URL in PHP requires passing the Location header and exiting thereafter: Though this method does work, I find it rather unclean. So, I prefer specifying the HTTP status code and also returning HTML/JavaScript for redirection. The HTML can be quite using when the page client is on a connection with very limited…
-
Ubuntu Upgrading from 12.04(Precise Pangolin) to 12.10(Quantal Quetzal)
Here’s how I upgraded to Ubuntu 12.10 from 12.04 sudo do-release-upgrade -d References http://www.unixmen.com/how-to-upgrade-from-uabuntu-1004-1010-1104-to-ubuntu-1110-oneiric-ocelot-desktop-a-server/
-
Code Syntax Highlighting in WordPress
Install the Crayon Syntax Highlighter through the WordPress Admin dashboard: Plugins -> Add New -> Search Plugins Code: <pre class=”theme:neon toolbar:2 nums:false plain:false scroll:true lang:ps mark:5 decode:true”> a@a:~$ ls -l total 972 lrwxrwxrwx 1 a a 44 2012-03-12 08:41 data -> /remote-server/data/ drwxr-xr-x 2 a a 4096 2012-03-12 08:30 Desktop drwxrwxr-x 2 a a 4096…