Jesus vs. The Beatles 2017 Featured

In 1966 John Lennon said “We’re more popular than Jesus now.” According to Google Trends, it is Justin Bieber who is bigger than Jesus. Except for Belarus. An obviously godless country with much better taste in music than the rest of Planet Earth. The #Prince or Michael Jackson question pretty much over too. Even Jesus kicks Prince’s ass…

Read more
  • IT

Replace text in mysql table

Sometimes you need to replace some text in your Mysql database. Whatever it is (a user ID or a user name), this is the SQL query you need to run:

update table_name set column_name = replace(column_name, ‘old-text’, ‘new-text’)

Read more
  • IT

Update Mysql table

This will update data in a MySQL table whether is empty or not.

UPDATE artists SET city = ‘Los Angeles’  WHERE city=’Sydney’

In this case Sydney will be replaced by Los Angeles.…

Read more
  • IT

Format 1000 to 1K and trim result to one decimal using PHP

In web design sometimes it’s neccesary to keep things short, so large numbers have to be trimmed for display. The following simple code will format any number > to 1000 to its 1K version and will limit decimals to 2 digits.

$shares = $this->page->shares;
$shares2 = $shares / 1000;
if ($shares < 1000) {
echo ‘$shares’;
else {
echo number_format($shares2, 2);
echo ‘k’;

With this simple code, a number preserves its format if it’s lower than 1000 (i.e.…

Read more
Back to top