Chrome DevTools – Quickly use currently selected element in console

I am sure like me, there’s been many times when using Chrome Developer Tools you selected an DOM element in the Elements panel and wished you could easily get a reference for it so you can use it in the console. It turns out it was possible and super-easy all along by using the $0 magic variable in Console. $0 automatically holds a reference to the currently selected element in the Elements panel. As a bonus the using $_ instead you get access to the last evaluated expression whether its an object or a scalar. Here’s how it looks:

$0 and $_ in Chrome Developer Tools

$0 and $_ in Chrome Developer Tools

 

 

Source: DevTips Daily

Read More

cup-dell-desk-4458

What motivates developers – and why I quit my old job

About a year ago I left my 9 to 5 job to pursue my own projects after way too many years stuck working at the same position for the same company. Today I stumbled upon this article that made me realize the true reasons why I quit, you can read it here. It turns out that all 3 points expressed in the article were what I was missing from my experience at the particular company.

  • Autonomy – micromanagement was the root of all evil. If as a manager you keep treating your employees as kindergarten children in time they will eventually start behaving like kindergarten children. Ultimately this killed any signs of team spirit and destroyed employee relations.
  • Mastery – the company culture imposed a slow pace, offered almost no training options (at least not in anything relevant to today’s standards), and experimentation with new technologies was treated by the management as toying around rather than doing useful work – essentially there was no long-term vision.
  • Purpose – developers are ‘creators’ in personality, they are people who gain satisfaction by knowing that their creations are being used. Being tasked to develop things that have no consequence, do not help anyone, are simply being funded as an excuse for the existence of the company in the eyes of its investors and you know beforehand that they will be just filed away as soon as they are completed. This alone is the most demotivating thing anyone can do to a software developer.

The worst part is that once you get comfortable in this culture it takes a long time to realize what is going wrong and how much it affects your way of thinking and your behavior in or outside the office. Like the article says, money was certainly not the issue. I was earning a decent salary, it could have been better but I guess it can always be better so I don’t count this as a factor. If you happen to be reading this and you are stuck in a situation like the one I  described I suggest you leave and never look back. New, better opportunities will come as soon as you exit the door.

Read More

bridge-coast-landing-stage-423

Recent & Worthwhile in Web Development

PHP

  • Remember Me – Safely Secure Long Term Authentication Strategies
    A detailed explanation on how to implement the Sign in ‘Remember Me’ functionality securely in PHP (the concepts are the same for every language). I must admit I never considered timing attacks for the authentication token until I read this.
  • Laravel 5.0 was released
    The 5th installment of one of the most popular PHP MVC and all-around frameworks was released. Wrote a summary of the changes in another post.
  • HHVM 3.5.0 Released
    The Facebook supported alternative PHP VM has a new version.
  • Cockpit
    A plug-n-play CMS for PHP sites. Targeted to developers, who built web apps and don’t want to re-invent the wheel every time for the content parts of their app. Uses SQLlite or MongoDB as data store.
  • Return Types Declarations approved for PHP7
    In PHP7 we’ll be able to declare the return type for functions and will be enforced causing a fatal error if a different type is returned.  Here’s an example of how it will look taken straight from the RFC:
    function foo(): array {
      return [];
    }

JS /HTML / CSS

  • ReactJS for Stupid People
    A good introduction on what Facebook’s ReactJS is about and why you should use it.
  • Animated Bezier Curves
    Demonstration of how parametric Bezier curves are constructed. Uses D3, and the code is straight forward, just View Source.
  • Konva JS
    Object-oriented 2D HTML5 Canvas Framework. Event driven, layer support, drag and drop, shape nesting, animation and all the usual bells and whistles.
  • mProgress.js
    Material Design style animated progress bar. Uses CSS3, has no other library dependencies and has beyond the ordinary features such as indeterminate progress (7.7kb minified JS).
  • RubaXa Sortable
    Minimal & customizable Sortable with touch support and no dependencies.
  • fieldVal
    Programmatic Javascript Field Validation library (runs both on browser and server). Includes an optional UI library for presenting validation errors in forms.
  • TauCharts
    Javascript charting library which aims to be flexible rather than offering pre-packaged chart setups.

Read More

PHP: array_walk vs foreach

Its a minor optimization but might make a difference if you process large arrays. Built-in PHP function array_walk allows you to apply a function to every element in an array. Obviously you can get the same results using a foreach. One would expect the built-in function to be faster since its written in C and hopefully has been highly optimized but it turns out, that’s not the case. After a bit of online research and some tests, foreach is the clear winner. Here’s the examples:

<?php
$test = array_fill(0, 10000, 'test_data');
$start = microtime(true);

foreach ($test as $key => $value)
{
    $result[$key] = 'testdata';
}

$end = microtime(true);
$time = $end - $start;
printf( "%0.5fs", $time );
Using foreach - 0.01022s
<?php
$test = array_fill(0, 10000, 'test_data');
$start = microtime(true);

array_walk($test, function($value, $index)
{
    $value = 'testdata';
});

$end = microtime(true);
$time = $end - $start;
printf( "%0.5fs", $time );
Using array_walk - 0.08700s

foreach wins. Case closed.

Read More

laravel-logo-white

Laravel 5.0 Final released

  • New project directory structure – now looks more intuitive.
  • Now more components implement interfaces for better extensibility.
  • Route Caching for faster performance.
  • Middleware support for routes.
  • Common Authentication functionality out of the box (controllers for authentication, registration, forgot password and their respective views are all included).
  • Job Scheduler so you only need to run one cron job and the scheduler picks what to run from the queued jobs for you.
  • and more…

Have a look at the release notes.

Read More

colors

New CSS draft includes support for Hex color values with alpha

By now you know that you can specify transparency in CSS color values (useful for properties like background-color) using the CSS RGBA function like this:

.transparent-blue {
   background-color: rgba(0, 0, 255, .5);
}

It turns out the new CSS Level 4 draft finally includes support for adding transparency to hex based color values – by using 8 digits instead of 6 giving 255 levels of opacity. Of course at the time this was being written its not supported by any browser but its good to know its coming. Here’s how it will look:

.new-transparent-blue {
   background-color: #0000ff88;
}

.new-transparent-blue-shorthand {
  background-color: #00f8;
}

Read More

How to mysqldump without auto increment values in Windows

In order to run PHPUnit tests I use a boostrap file which uses mysqldump to export the ever-changing database schema without any data, and import it into the testing database. After using this method for a while I stumbled on a problem with the auto-increment values for the table primary keys. There is no easy way to get mysqldump to avoid including the next auto-increment value in the dump. The problem this causes is that if your tests depend on specific primary key values things will go wrong the second time you run your test suite. There is a way to fix this by piping mysqldump’s output into sed. Here’s the actual command:

mysqldump -d [devDB] | sed 's/AUTO_INCREMENT=[0-9]*//' >

This will work under Linux but sadly not on Windows which doesn’t have sed but there’s a solution for that. (more…)

Read More

lg g2 android 5 lollipop

LG G2 will get Android 5.0 Lollipop

LG “officially” confirmed that LG G2 will receive a firmware update for the latest version of Android 5.0 Lollipop sometime during early 2015. The news came in the form of a Facebook post on LG Germany’s page mentioning that LG G2 Android 5.0 ‘is coming’, you can view the post below. The latest LG flagship phone, the LG G3 already received Android 5 in Poland (probably released in one market to test it before going worldwide) and as you can see in the video below it looks quite good. Even though the important changes are under the hood it appears they haven’t changed LG’s own skin a lot (layouts are the same, options are where they used to be), but at least the use of Google’s material design guidelines is apparent throughout. Maybe for G3 it didn’t take that much work since the UI was already  along the lines of Android 5.0 so the interface changes for G2 will be much more visible. So I guess this will keep my 1 year old G2 alive for another year until LG G4 comes out and start considering an upgrade.

 

 

Read More

hubiC1

hubiC cheap 10TB cloud storage and Dropbox new pricing

There have been some updates in the cloud storage industry since my last post

hubiC – new cloud storage provider

First time I heard of hubiC I thought ‘yet another cloud storage provider’ but I was wrong. hubiC is a product of OVH one of the largest Internet Service Providers in Europe which has been around for 15 years. Their headquarters and most of their data-centres are based in France, hosting 170000 servers (and 18 million websites). I used to rent a dedicated server from them for a couple of years and I had absolutely no problems with them. Being this large and old it hopefully also means it won’t disappear along with my data tomorrow and that they have more than basic knowledge of network security to keep my data safe. They give 25GB space for free and 100GB for 1 euro per month (inc vat) undercutting Google Drive by about 50 cent per month – not really worth switching providers for. Where hubiC shines though is their 2nd tier package at 10TB for 10 euro per month. Here’s a quick list of features:

  • Owned by a large company with many years experience in cloud and hosting
  • Windows, MacOS, Linux, Android, iOS, Windows Phone and Blackberry clients.
  • Based in Europe means faster for us than Dropbox and Google Drive.
  • 10TB for 10 euro (0.1 cent per GB per month)

One concern I have about hubiC is that if its desktop apps work the same way as Dropbox it means it will be really hard to ever utilise the whole 10TB. Dropbox for example mirrors what you have stored on your dropbox folder to the cloud and any other desktop client you have running with the same account which means if you fill up 1TB of space, you need 1TB of space on your Laptop too. Consider the same with 10TBs. I will test their Windows app using the 25GB free package and post about it later.

Check hubiC out at here.

Update 1:
Tested upload speed with a bunch of RAW Image files totalling 300mb on 3mbit upstream. hubiC averaged to 325kb/s upload speed.
On their web interface if you choose more than one file to download, it sends you a ZIP file containing the selected files.

Dropbox “dropped” the price

Dropbox took its time but followed Google Drive’s and Microsoft OneDrive’s example and decreased its prices. They simplified their paid plans; now only one non-business option is available and costs 9.99 euro per month for 1TB if paid monthly (which is about 10 times more expensive than hubiC) or 99.99 per year. If you are US based you get the same for 9.99 USD, which means we are getting ripped off as usual.

Read More

online-shopping

Online Shops that ship to Cyprus

Its extremely frustrating to find a product you want to buy online only to realise they don’t ship to your country (and to do so, sometimes you have to go through the process of filling up 3 pages of sign up forms). Living in Cyprus which happens to be too small to be a viable marker for many its very rare to find online stores that care to send their products all the way to us. So I made the following list of places that I’ve either ordered before or I know that ship to Cyprus. I plan to keep this list updated as I find new Cyprus-friendly shops – and if you know any I missed, please let me know. So here’s my list:

 

Site Ships from Products & Notes
Play.com UK (and more) Video games, Books, BluRay/DVD, Mobile accessories, Limited selection of clothes. Sells other products too but doesn’t ship to Cyprus.

Used to ship to Cyprus for free when it was a single shop but now it became a reseller platform so some sellers will send for free some for a small fee. But in general they do send to Cyprus without a problem.

Game UK UK Video Games, Console accessories.

Good prices, has new games on time. No free shipping but cost with shipping usually comes about the same as Play.com

Zavvi UK Video Games, Movies and limited range of computer products/laptops.

Quotes prices in Euro and has free shipping to Cyprus via Post for most items. Appears a bit more expensive than Game.co.uk on the items I checked but might be compensated by the free shipping.
(Thanks to Dimitris Georgiou for the tip)

Overclockers UK UK Laptops, Desktops, PC Components.

Best shop for hardcore PC gamers. Has custom built gaming machines, and a great selection of high end PC components. If you are building a powerful PC, you should look here first. Prices are OK (you can probably find cheaper if you look elsewhere). They might give you some trouble when ordering from Cyprus, in the past I was asked to send a scan of my passport, but after that they sent my order without any delays.

Computer Universe Germany General Electronics, Laptops, Mobile Phones, Tablets, Cameras, Lenses, PC Components, HiFi.

Only found out about this store recently and haven’t had the chance to order from them yet. But compared to other sources they seem to have the cheapest PC components and a good selection of them. Also their laptop section has almost everything you’ll need. They ship using regular post (DHL in Germany but you’ll receive your product in the Post Office in Cyprus) or UPS which costs considerably more.

B&H Photo USA Everything Photography Related, Laptops, Tablets, Professional Audio & Video, TVs and Projectors.

One of the few US based shops that will ship any of its products to Cyprus. If you are interested in photography this is the site to check. They sell cameras, lenses, tripods, lights, filters accessories and anything a photographer might need, from the cheapest snap cam to the most expensive and rare SLR Lens. The prices are good you will have to pay taxes in Cyprus since they ship from outside EU, so in some cases check amazon.co.uk or ebay.co.uk for the same products before ordering. They ship via UPS or Air Freight for large items such as TVs (which can be costly). They also offer the option to prepay taxes through their site. Personally I never used that option and it turns out you pay a little less tax in Cyprus.

Adorama USA Photography, Laptops, Tablets, Professional Audio & Video, TVs and Projectors.

Similar product range with B&H Photo, ships to Cyprus via UPS.

Clove UK Mobile Phones, Tablets & Related Accessories.

Never used them myself but I know people who did and are quite happy. They have the latest handsets in stock almost immediately after release (usually earlier than Cyprus retailers) and their prices are quite good. In addition to credit cards they also support PayPal which is a plus.

HandTec UK Mobile Phones, Tablets, GPS.

Similar product range to Clove, but appears to be slightly cheaper (at least for Samsung and LG models I checked).
(Thanks to Michael Demetriou for the tip)

Please note I am not including any Chinese stores, since there is literally hundreds (if not thousands) of them that usually sell the same products via drop-shipping and they all super happy to ship to Cyprus (usually for free via regular post). I might write another post about Chinese shops in the future.

I also don’t include Amazon.co.uk because a lot of its sellers won’t send products to Cyprus.

If you know of any other shops that you think should be included in the list above please post about them and your experiences in the comments.
 

Read More