Friday, April 21, 2017

Smart Social Content: The 2017 #SocialMedia Image And Video Size Guide (infographic)

If you're a marketing professional you know the importance of social media and the role it plays in attracting new customers. But what many people don't realize is that merely having a social media account isn't enough (although it certainly helps.) The best social media accounts have...

[ This is a content summary only. Visit our website http://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Irfan Ahmad via Digital Information World

10 Easy WordPress Security Tips

WordPress is not inherently insecure and the developers work hard to ensure breaches are patched quickly. Unfortunately, WordPress's success has made it a target:

  • not all themes and plugins are developed with the same level of care
  • if you can break just one WordPress installation, many millions of sites may be open to you.

Some will attack WordPress for the challenge or to cause malicious damage but those are easy to spot. The worst culprits sneak links into your content, place phishing sites deep within your folder structure, or use your server to send spam. Once your installation is cracked, it may be necessary to delete everything and reinstall from scratch.

Fortunately, there is a range of simple options to improve security. None of the following security fixes should take longer than a few minutes.

Continue reading %10 Easy WordPress Security Tips%


by Craig Buckler via SitePoint

How to Take Control of Page and Post Revisions in WordPress

This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible.

WordPress provides a revisions system which records a full copy of every page and post when it's saved. The advantage: you can revert to an earlier version of the document at any time, make comparisons and discover who's to blame for spolling or error grammatical.

By default, there is no limit to the number of revisions stored per page or post. (Note only a single auto-save is made per post per editor -- the most recent auto-save overwrites the previous one.) Every revision requires a separate row in WordPress's posts table and perhaps multiple entries in the postmeta and term_relationships tables. That's rarely a problem for smaller sites but it could affect the performance and efficiency of larger installations. Tables eventually become filled with redundant data which will never be used.

Limiting Revisions

The number of revisions can be set in WordPress's wp-config.php file.

Continue reading %How to Take Control of Page and Post Revisions in WordPress%


by Craig Buckler via SitePoint

#331: Arrow functions, popular JS patterns, and React VR

This week's JavaScript newsRead this e-mail on the Web
JavaScript Weekly
Issue 331 — April 21, 2017
Eric felt some pushback against the use of ES6’s arrow functions recently. Here he explains how they’re useful and why you should become very comfortable with them.
Eric Elliott

A 50 minute roundup of common, JavaScript-specific techniques like using modules, webpack, ES6 syntax, classes, async/await and more.
Scott Allen

React VR lets anyone with an understanding of JavaScript rapidly build and deploy VR experiences using standard web tools. GitHub repo.
Facebook

Bitmovin
An easy to integrate and versatile HTML5 based MPEG-DASH and HLS player for desktop, mobile, VR Headsets, Chromecast, AirPlay, AppleTV and SmartTVs. Including a WebGL based VR and 360 video component and a completely customizable HTML5/CSS UI.
Bitmovin   Sponsor

An open source project to bring better validation to Angular’s reactive forms. Here’s a look at how to use it, why Todd created it and the problems it aims to solve.
Todd Motto

Should you pick Angular or React? Pavels Jelisjevs looks in detail at what both frameworks have to offer, and gives some practical advice on how to choose.
Sitepoint

The basics of turning an expression like 89sin(60) + 4.4x/9 into its component parts for further processing.
Shalvah Adebayo

A look at some key new features in Microsoft’s Chakra JavaScript engine.
Limin Zhu

Jobs Supported by Hired.com

Can't find the right job? Want companies to apply to you? Try Hired.com.

In Brief

Nordic.js (Sep 7-8 in Stockholm) Call for Proposals Open news

JSConf Budapest (Sep 14-15) Call for Speakers Open news

Facebook Announces React Fiber, A Rewrite of React's Internals news
TechCrunch

Full-day Workshop: Using ES6 and React with Netflix's Brian Holt course
Forward Courses  Sponsor

You Need ES2017's Async Functions. Here's Why tutorial
Derick Bailey

A Look At Async Iterators and Generators tutorial
Jake Archibald

A JS Testing Tool Showdown: Sinon.js vs testdouble.js tutorial
SitePoint

How Method Binding Is An Implicit Part Of Your API Contract tutorial
Ben Nadel

Using ReactJS, ES6 & JSX to Build a UI (the rise of MERN) tutorial
Part 5 of our Modern Application Stack series - Why ReactJS is driving the development of modern applications.
MONGODB  Sponsor

CodeSandbox: An Online React Playground/Editor tools
See our React newsletter for more like this.
Ives van Hoorne

Tinytime ⏰: A Simple strftime-esque Time and Date Formatter code
Brandon Dail

lodash-form-collector: A Form Collector Package Powered by Lodash code

Chroma.js: Library for Color Conversions and Color Scale Generation code
Gregor Aisch

HR.js: A Tiny Library for Highlighting and Replacing Text in the DOM code
Mehmet Burak Erman

D3-Annotation: Easily Add Annotations to D3 Visualizations code
Susie Lu

Polished: A Toolset for Writing Styles in JS code
.. complete with Sass-style helper functions and mixins.
Glen Maddern and Maximilian Stoiber

Simple Slider: A 1KB JavaScript Carousel code
An extremely lightweight carousel micro library. Demo on homepage.
Ruy Adorno

React InstantSearch ⚡ Lightning Fast Search for Web and Native Apps tools
Build instant search for your app in a few lines of code. UI widgets give you a great search out of the box.
Algolia  Sponsor

vee-validate: A Simple Vue.js Input Validation Plugin code
Abdelrahman Awad

Pandemonium: 10 Randomness-Related Functions code
Things like weighted choices, sampling, and shuffling.
Guillaume Plique

Curated by Peter Cooper and published by Cooperpress.

Like this? You may also enjoy: FrontEnd Focus : Node Weekly : React Status

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

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


by via JavaScript Weekly

Shared Server Hosting: the Pros and Cons

The range of hosting options has become bewilderingly complex during the past few years. The basics are simple: a computing device has software installed which can respond to a network event such as a request for a webpage. How that hardware and software is installed, configured, organised, packaged, promoted and sold is the primary difference between all hosting options.

Those running large websites or applications could opt for a dedicated server. This would provide a device for their sole use in a data center capable of handling with thousands of daily visitors and heavy processing.

However, a dedicated server is overkill for the vast majority of websites with a few dozen pages receiving a few hundred visitors per day. The cost would be prohibitive and the device would run idle most of the time. Shared hosting becomes a more viable option.

Web hosts such as SiteGround provide shared servers where you lease private space for your website. Many other companies will be leasing space on the same device so the processing, storage and costs are shared accordingly. In essence, it's a dedicated server with multiple users.

Continue reading %Shared Server Hosting: the Pros and Cons%


by Craig Buckler via SitePoint

Animating an Android Floating Action Button

Since Material design was introduced, the Floating Action Button (FAB) has become one of the simplest components to implement, becoming a fast and essential favorite amongst designers and developers.

In this tutorial I will show you how to make your apps FAB interactive and how to make your own animations. But let’s start simple, adding the Floating Action Button to an Android project.

Continue reading %Animating an Android Floating Action Button%


by Valdio Veliu via SitePoint

How to Create a Laravel Helper

To begin with, I would rather let the Laravel official site speak about helpers.

Laravel includes a variety of global "helper" PHP functions. Many of these functions are used by the framework itself; however, you are free to use them in your own applications if you find them convenient.

So, basically, helpers in Laravel are built-in utility functions that you can call from anywhere within your application. If they hadn't been provided by the core framework, you might have ended up developing your own helper classes.

Although the core provides a variety of helpers already, there’s always a chance that you’ll need your own and would like to develop one so you don’t have to repeat the same code here and there, thus enforcing better maintainability. You'll learn how to create a custom Laravel helper in this tutorial.

Helpers in Laravel

As we discussed earlier, there are plenty of helpers available in the core of the Laravel framework. They are grouped together based on the functionality they provide. Here’s a list of helper groups.

Arrays

Helpers in this group provide functionality to manipulate array elements. More often than not, you're in the situation where you want to perform different operations on array elements. So this is the place where you should look first to see if what you're looking for already exists.

Paths

I find helpers in this category most useful. They return the fully qualified path of different directories like app, storage, config, and the like. I bet you're using most of these helpers already in your Laravel application.

Strings

String manipulation is something inevitable in your day-to-day application development. Although there are plenty of string manipulation functions provided by PHP itself, you'll find a few more useful goodies in this section.

URLs

You'll find very few in this category, but they are used throughout the application. They are used to generate route, asset, and form action URLs.

Miscellaneous

This category contains helpers that provide a variety of functionalities ranging from logging to debugging and many more.

For a complete reference of Laravel helpers, there's no better place than the official documentation.

Create Your First Custom Helper

Now you have a basic understanding of Laravel helpers and what they are used for. In this section, I’ll go ahead and demonstrate how you can create your own custom helper that can be used globally in your Laravel application.

To keep things simple and easy to understand, it’ll be a pretty basic helper that takes a userid and returns a username as a response. Of course, that doesn’t sound fancy, but I believe it’s enough to demonstrate the concept, and you could always extend it to fulfill your complex requirements.

I assume that you have a users table in your database and it has at least two fields—userid and username.

The Skeleton of a Laravel Helper

Before we move ahead and actually create the files, let’s have a quick look at the files that we’re going to create in the rest of the article.

  • app/Helpers/Envato/User.php: It’s our helper file that holds the logic of our helper.
  • app/Providers/EnvatoServiceProvider.php: It’s a custom service provider file that loads our custom helper file.
  • config/app.php: In this file, we’ll declare our custom service provider, and it also helps us to define an alias to our helper so that we don’t have to use the fully qualified class name of our helper.
  • routes/web.php: A pretty standard Laravel route file where we’ll actually test our helper.

Create Helper Files

Although you could place your helper files anywhere in your application, the more intuitive and standard way suggests that it should go under your app directory.

So go ahead and create a Helpers/Envato directory under app and create a User.php file with the following contents. Of course, you could place it directly under the app or app/Helpers directory, but providing that extra level allows us to organize our helpers in good shape, specifically when you’re going to have plenty of them.

The file starts with a pretty standard namespace declaration:

The purpose of our custom helper is to retrieve a username based on a userid. Hence, we need to interact with the database, and that forces us to include DB Facade.

For those who are not familiar with Laravel Facades, it’s just another convenient way to access the objects in service containers. Alternatively, you could have used dependency injection.

Moving ahead, there comes the concrete implementation of our helper. As you can see, there’s a static method that defines the logic of retrieving a username based on a userid.

The $user object holds the database record with the matching userid. Finally, the method returns the username as a response in the following statement.

That’s it as far as our helper file is concerned.

Now we’ve created our helper file, but the question is how are you going to use it? Two quick solutions come to my mind:

  • You can include our helper filename in the composer.json, so that it gets auto-loaded. Then, you could straight away call the static method of our helper class.
  • You can go ahead and create a Laravel service provider that allows you to register your custom helper file so that the Laravel framework loads it along with other dependencies. Register that service provider in the Laravel configuration and create an alias to use your helper.

Of course, the first one is pretty quick and easy to implement, and you might be tempted to do so, but I would rather suggest the latter one as it looks like more of an artisan way and is more maintainable.

Move to the command line and run the following command in your application root to create a new service provider.

You should see the message that confirms that it’s created successfully under the app/Providers directory.

Open that file and you should already see two methods out there. The important one in the context of this article is the register method. Yes, it’s empty at the moment, so let’s feed in some stuff to make it more useful.

The register method is used to register your dependencies, and we’ve exactly done that. We’ve included our custom helper file.

Here’s how the app/Providers/EnvatoServiceProvider.php file should look after modifications.

So it’s all pretty good so far. We have our custom helper and service provider on the table.

Next, we need to inform Laravel about our service provider so that it can load it during bootstrapping. Let’s open the config/app.php and add the following entry in the providers array at the end.

To use our helper in a convenient way, we could create an alias as well. So let’s do that by adding the following entry in the aliases array at the end in the same file.

By defining this entry, we can call our helper by using the EnvatoUser keyword. Pretty convenient, huh? For your reference, here’s the complete config/app.php file.

We’re almost there! We’ve done all the hard work to get here, and now we can reap the benefits of our custom helper.

Your First Custom Helper in Action

Again, to keep things simple and straightforward, we’ll define a basic Laravel route and call our helper from there!

Go ahead and create a routes/web.php file with the following contents.

Does that need any explanation at all? We’ve just called the custom helper by the shorthand EnvatoUser::get_username, and it should return the username.

Of course, you can call our helper from anywhere in the application, be it a controller or view.

So that ends our story for today.

Conclusion

Helpers in Laravel are really a powerful feature, and I'm sure that as a developer you would love to extend that. And that was the topic of today—we went through the basics of the Laravel helper file structure and created a useful custom helper.

I hope you’ve enjoyed the article and it helps you create your own custom helpers in day-to-day Laravel application development.

Don’t hesitate to leave your comments and queries in the feed below. I also catch comments on my Twitter and respond to them as soon as I can!


by Sajal Soni via Envato Tuts+ Code