Friday, November 13, 2015

Watch: Get the Right File Permissions in Your WordPress Site

Changing your WordPress permissions might seem trivial, but it's a small step you can take to improve your website security. Learn how to set permissions yourself, confirm they're correct, and also how to overcome the side effect. In just a few minutes with this video, I'll show you exactly how to do that. Enjoy!

Loading the player...

Continue reading %Watch: Get the Right File Permissions in Your WordPress Site%


by Charles Costa via SitePoint

SitePoint Ambassador of the Month: November 2015

A lot of things brew in the SitePoint kitchen, which we're always excited to talk about. Something I've been devoting my time to recently is our very popular Ambassadors Program. We launched the Ambassadors Program back in May, 2015, to provide a common focus for SitePoint contributors passionate about the content, community and philosophy of […]

Continue reading %SitePoint Ambassador of the Month: November 2015%


by Elio Qoshi via SitePoint

Core Data and Swift: More NSFetchedResultsController

Suggesting Carbon with Composer – Date and Time the Right Way

Carbon is a small library for date and time manipulation in PHP. It relies on and extends the core DateTime class, adding helpful methods for a significantly saner experience.

In this article, we’ll take a look at some basic usage examples, and then use it in a real project.

Date and time image

Introduction

Carbon is just a class which is designed to be used instead of DateTime. Due to extending DateTime, all DateTime methods are available to users of Carbon. Additionally, it implements a __toString method, allowing users to put it in place of string representations of date and time as well.

It can easily be installed with Composer:

composer require nesbot/carbon

Let’s see some example uses, as presented in their excellent documentation.

Example Uses

The easiest way to get started with Carbon is to just pass a human readable date string into its constructor, along with an optional timezone - if the timezone is omitted, the one set by the current PHP installation will be used.

$carbon = new Carbon('first day of next week');

It can also be instantiated from strings, timestamps, even other instances of DateTime or even Carbon. The instance can be copied with the copy() method, for efficient cloning.

From there, we have access to a smorgasbord of helper checkers and getters:

$carbon->isWeekend();
$carbon->isFuture();
$carbon->isLeapYear();

$carbon->year;
$carbon->month;

$carbon->daysInMonth;
$carbon->weekOfYear;

The package also exposes static methods for creating new instances quickly:

echo Carbon::now()->addYear()->diffForHumans();    // in 1 year

Even birthdays can be checked, as we can see by this example from the docs:

$born = Carbon::createFromDate(1987, 4, 23);
$noCake = Carbon::createFromDate(2014, 9, 26);
$yesCake = Carbon::createFromDate(2014, 4, 23);
$overTheHill = Carbon::now()->subYears(50);
var_dump($born->isBirthday($noCake));              // bool(false)
var_dump($born->isBirthday($yesCake));             // bool(true)
var_dump($overTheHill->isBirthday());              // bool(true) -> default compare it to today!

Localization

Localization is also supported, so that output can be given in any desired language installed on the machine powering the PHP app. Note that you do need to install the necessary locales for this to work - refer to your operating system’s documentation for details on how to do that.

To localize date and time strings, the standard PHP function setlocale can be used:

setlocale(LC_TIME, 'German');
echo $dt->formatLocalized('%A %d %B %Y');          // Mittwoch 21 Mai 1975

To localize the diffForHumans method which outputs a human-readable difference in time, the class offers its own setLocale method:

Carbon::setLocale('de');
echo Carbon::now()->addYear()->diffForHumans();    // in 1 Jahr

Interval

A CarbonInterval class is also provided, which is an extension of DateInterval. Self-descriptively, it holds interval values, just like the base class, but adds helper methods on top. As per examples:

echo CarbonInterval::year();                           // 1 year
echo CarbonInterval::months(3);                        // 3 months
echo CarbonInterval::days(3)->seconds(32);             // 3 days 32 seconds
echo CarbonInterval::weeks(3);                         // 3 weeks
echo CarbonInterval::days(23);                         // 3 weeks 2 days
echo CarbonInterval::create(2, 0, 5, 1, 1, 2, 7);      // 2 years 5 weeks 1 day 1 hour 2 minutes 7 seconds

Note that Carbon as a whole is exceptionally well documented - for a full reference of methods and usage examples, please see their docs.

Implementation

In this section, we’ll upgrade the Diffbot PHP Client to optionally support Carbon. The plan is as follows: if the user has the library installed, then the Article entity and Post entity will return Carbon instances instead of date strings from their getDate and getEstimatedDate methods. Otherwise, they’ll return strings as usual.

Continue reading %Suggesting Carbon with Composer – Date and Time the Right Way%


by Bruno Skvorc via SitePoint

The Ethics and User Experience Behind Programming Cars

Cars have come a long way from the days of the Ford Model T. While it used to be enough for a car to have Bluetooth and phone integration, software now controls the entire driving experience. From entertainment systems to engine operations, safety systems and more. Technology has led to innovations such as intelligent cruise control, parallel parking assist and even automatic overtaking, yet none of these are as impressive as the self-driving features Google and some Tesla vehicles sport.

Programming cars used to be limited to engineers with years of experience in the automotive industry. Today, with advanced programming interfaces, coding for cars is much more accessible. It’s still not as easy as coding a website, but at least you don’t need to master embedded systems programming to make modifications to cars. Unfortunately, that’s a whole different topic beyond the scope of this article. Instead we’re going to focus on a few non-technical challenges to programming cars.

Continue reading %The Ethics and User Experience Behind Programming Cars%


by Charles Costa via SitePoint

This week's JavaScript news, issue 258

This week's JavaScript news
Read this e-mail on the Web
JavaScript Weekly
Issue 258 — November 13, 2015
An extensive look, complete with helpful diagrams, at how to architect an Angular application so that it can comfortably grow over time.
Kristian Poslek

A series of interactive exercises for learning Microsoft’s Reactive Extensions (Rx) Library by initially tackling plain JS functional concepts.
ReactiveX

This spawned a lot of discussion but is well worth reading if you’re looking for a job in this space.
Reddit

Future Proof Your Apps. Telerik Platform 2.0 changes the game in mobile app development, enabling you to build beautiful apps with a rich user experience, fast and efficiently. Webinar Dec. 3, 2015 | 11 am ET. Save my seat.
Telerik   Sponsored
Telerik

A walk through of creating a system using HTML5 Canvas and getUserMedia to detect how far a user is away from their screen. (Note: Demos won’t work on Chrome 47+ due to getUserMedia being disabled on insecure origins.)
SitePoint

The official European Angular conference wrapped up a few weeks ago and here are a variety of insights and news from the event. Want to watch the actual talks? Enjoy these 41 videos.
Angular Team

This tool produces visualizations of where all the code in your minified JS came from so you can either optimize or justify your file sizes.
Dan Vanderkam

A demonstration of how Asm.js-based JavaScript can run a lot faster through a chess match where Asm.js optimized and non-optimized players get 200ms each turn to find the best move.
Microsoft Edge Dev

A fun walk through a developer’s project to play old-school tracker music files in the browser using JavaScript.
a1k0n

Jobs

  • Senior JavaScript Developer (m/f) at ShoreShore is looking for passionate developers who breathe JavaScript. Join a startup & write production-ready ECMAScript 2015 in an agile environment. Promise.resolve('challenge').then((c) => You.accept(c).at(Shore)) Shore GmbH
  • Expert JavaScript Instructors at Pluralsight (Freelance-Part-time)Currently hiring expert JavaScript Developers that want to share their knowledge with a global audience. As a Pluralsight author, you'll join a tight knit family of passionate teachers and earn royalties. We are looking for the best communicators and presenters in the developer community. Apply today. Pluralsight
  • Applying For Jobs Is So YesterdayGet interviews with top companies without submitting another application. Through Hired, companies find you - and offer salary and other benefits upfront. Hired.com

In brief

Curated by Peter Cooper and published by Cooper Press.

Stop getting JavaScript Weekly : Change email address : Read this issue on the Web

© Cooper Press Ltd. Office 30, Lincoln Way, Louth, LN11 0LS, UK


by via JavaScript Weekly

Laps

Laps - Ultimate toolset for modern freelancer

Clean responsive One Pager for a new freelance project management and invoicing app called 'Laps'. Quite like that neat table showing development progress.

by Rob Hope via One Page Love