Samsung Unveils Galaxy S8 and S8 Plus

“Unbox your phone”. That’s the message behind the newest flagship device by Samsung, revealed today in a conference that was live streamed on Samsung’s Facebook page and YouTube channel.

Highlights of the new Galaxy S8 and S8+:

  • Bixby – the intelligent AI software (ahem, Siri competitor), integrated with the Camera app and other default Samsung apps. You invoke Bixby by pointing the camera at the object of interest or speak to it.
  • No bezels – Over 90% display to body ratio
  • Curved edge display by default – where the curved display was a feature exclusive to the plus versions earlier, now it’s available to both models

Below is the full reveal video.

https://www.youtube.com/watch?v=D8Ert5yjMV4

Angular 4.0.0-rc.6 released

Angular 4 Release Candidate 6 has just been released today (23 March 2017). The list of features and bugs fixed can be seen in the changelog, but the most important fixes are in the areas of the animations and small fixes to the compiler. No significant or backward incompatible changes are introduces compared to Angular 4.0.0-rc.5.

Download Angular 4.0.0-rc.6

Here’s the full changelog:

Creating a simple Angular 2 CRUD app, based on the MEAN stack

Angular2, Node.JS, Express and Mongo – one of the preferred stacks for fresh developers and experienced ones. Being a full-fledged solution that covers the frontend, server-side and database storage of things, the MEAN stack is an easy way to get going with any small to medium sized project.

In this tutorial, you’ll see how to create a simple Angular2 based frontend application for managing your book collection in a list based manner, taking advantage of variety of technologies offered by Google’s library like – services, components and the Angular2 routing.

The backend will be powered by the NodeJS technology, which has the all-familiar JS syntax. But don’t be confused by the fact that JS is mostly a frontend development language. In this example, NodeJS empowers one of its popular frameworks for serving a backend web server – Express.

All data persistance happens in a MongoDB database (stored locally, but can also be connected to a remote production/development server). MongoDB is a popular NoSQL storage engine that is good for storing big chunks of non relational data.

The stack also contains the standard CRUD operations – add, edit, delete a book. It’s the perfect example for starting a real world Angular2 based application.

Read the tutorial

Installing Docker Toolbox on Windows (Video)

Docker is a very powerful and lightweight virtualization engine that allows you to run any linux machine inside (almost) any host environment. The following tutorial will teach you how to install the Docker host inside Windows and how to run a few of the most populate commands to get you started in the Docker world.

What you’ll need to get Docker running on Windows:

  • A Windows computer
  • Docker Toolbox – a package of all the software needed to have a fully functional environment to run Docker containers (available as Mac or Windows installation package)

Get the First Value in a Array (with and without resetting the array pointer)

 

At first sight this question seems like a trivial one – “how to get the first element’s value in a PHP array?”. Most people would answer with:

  $firstElem = reset($array);

This will work for 90% of the cases, but is not a possible approach every time for the following reason:

reset() rewinds array’s internal pointer to the first element and returns the value of the first array element. from the PHP documentation for reset()

So forget about using current() and next() on that array if you use reset() on it.

To overcome this pitfall, we can use a different approch:

function getFirstElem(array $arr){
    return array_shift(array_values($arr))
}

$firstElem = getFirstElem($myArray);

This will make a copy of the array’s values and get the first element from that copy. Using this approach your internal pointers to $myArray will not be lost.

(Image credit by “Andre Chinn”)

How to Unset/Remove a Cookie Immediately with PHP (Even for the Current Request, Without Having to Refresh the Page)

 

Setting cookies is generally done using setcookie(), that’s a known fact. However, unsetting them generally is a bit trickier, since the cookie remains available throughout the current request, if requested via the global variable:

$_COOKIE['the_cookie_name']

The cookie is fully removed/expired on the next page refresh.

The function below will avoid this behavior. It will still remove the cookie on the next page request, but it will also make it unavailable during the current request too, essentially “expiring”/”removing” it immediately.

function removeCookie($cookieName){
    unset($_COOKIE[$cookieName]);
    setcookie($cookieName, '', time() - 3600, '/');
}

To remove e.g. a cookie named “last_username”, you would call:

removeCookie("last_username");

Image credit to @Ginny