Friday, March 10, 2017

The Best WordPress Photo Plugins for Photographers

If you’ve done well enough to snap a group of photographs you deem worthy of display, then figuring out the best WordPress plugins to show them off is essential.

When you’re using WordPress and you think, ‘I wonder if there’s a plugin for that?’ The answer is almost always yes—multiple plugins! But space and speed are not always plentiful in the WordPress world and having too many plugins can clutter up your site, so prioritising is key. The trick is not to settle on just any of them, but to find the best one.

So below is a little collection of some of the best and most trusted photography plugins to save you wading through the masses, or worse, making completely the wrong choice.

Continue reading %The Best WordPress Photo Plugins for Photographers%


by Sally Wood via SitePoint

Crash Course: Continuous Deployment with Semaphore CI

Software is playing an ever bigger role in how companies compete across a broad range of industries. Large organizations are finding that their current approaches to managing software are limiting their ability to respond as quickly as business requires. Continuous delivery helps with this.

Semaphore CI logo

Understanding continuous delivery, a now already long-standing buzzword, is not a problem, but implementing it in the right way has been a challenge for quite a few of us, and one we'll discuss in this post.

Getting Started

We can easily upload our files to a server using an open source desktop client like Filezilla. Those who have used this are aware that this process is cumbersome and irritating as it doesn't let us automate the deployment process, and we always end up having to upload the whole project, even if we have modified only a part of it. Alternatively, we could do a git pull on the server and our application is instantly in its latest state, but this workflow doesn't work in today's world where we have to continuously deliver software to our end users bug-free.

In this article, we will cover the process of deploying a Laravel application on a Digital Ocean server through a continuous delivery pipeline using Semaphore. The source code for the application is present on Github.

Set up a Project on Semaphore

First, create a Semaphore account. After signing up, we see a page to create a new project.

Create Project

We then have to select the account where our repository is present. If you haven't connected your source code repository provider with Semaphore, you can do so in this step. Semaphore natively supports Bitbucket and Github.

Select Account

If you forked the aforementioned repo, you can select it in this step:

Select Repository

Continue reading %Crash Course: Continuous Deployment with Semaphore CI%


by Viraj Khatavkar via SitePoint

DRY Your Python Code With Decorators

Decorators are one of the nicest features of Python, yet for the beginner Python programmer, they can seem like magic. The purpose of this article is to understand, in depth, the mechanism behind Python decorators.

Here's what you'll learn:

  • what are Python decorators and what they are good for
  • how to define our own decorators
  • examples of real-world decorators and how they work
  • how to write better code using decorators

Introduction

In case you haven't seen one yet (or perhaps you didn't know you were dealing with one), decorators look like this:

You usually encounter them above the definition of a function, and they're prefixed by @. Decorators are especially good for keeping your code DRY (Don't Repeat Yourself), and they do that while also improving the readability of your code.

Still fuzzy? Don't be, since decorators are just Python functions. That's right! You already know how to create one. In fact, the fundamental principle behind decorators is function composition. Let's take an example:

What if we wanted to create another function, x_plus_2_squared? Trying to compose the functions would be futile:

You cannot compose functions in this way because both functions take numbers as arguments. However, this will work:

Let's redefine how x_squared works. If we want x_squared to be composable by default, it should:

  1. Accept a function as an argument
  2. Return another function

We'll name the composable version of x_squared simply squared.

Now that we've defined the squared function in a way that makes it composable, we can use it with any other function. Here are some examples:

We can say that squared decorates the functions x_plus_2x_plus_3, and x_times_2. We are very close to achieving the standard decorator notation. Check this out:

That's it! x_plus_2 is a proper Python decorated function. Here's where the @ notation comes into place:

In fact, the @ notation is a form of syntactic sugar. Let's try that out:

If squared is the first decorator you've ever written, give yourself a big pat on the back. You've grasped one of the most complex concepts in Python. Along the way, you learned another fundamental feature of functional programming languages: function composition.

Build Your Own Decorator

A decorator is a function that takes a function as an argument and returns another function. That being said, the generic template for defining a decorator is:

In case you didn't know, you can define functions inside functions. In most cases, the decorated_function will be defined inside decorator.

Let's look at a more practical example:

Sweet! Now you can be sure that everything inside your app is standardised for the UTC timezone.

A Practical Example

Another really popular and classic use-case for decorators is caching the result of a function:

If you look at the code shallowly, you might object. The decorator isn't reusable! If we decorate another function (say another_complex_computation) and call it with the same parameters then we'll get the cached results from the complex_computation function. This won't happen. The decorator is reusable, and here's why:

The cached function is called once for every function it decorates, so a different _cache variable is instantiated every time and lives in that context. Let's test this out:

Decorators in the Wild

The decorator we just coded, as you may have noticed, is very useful. It's so useful that a more complex and robust version already exists in the standard functools module. It is named lru_cache. LRU is the abbreviation of Least Recently Used, a caching strategy. 

One of my favourite uses of decorators is in the Flask web framework. It is so neat that this code snippet is the first thing you see on the Flask website. Here's the snippet:

The app.route decorator assigns the function hello as the request handler for the route "/". The simplicity is amazing. 

Another neat use of decorators is inside Django. Usually, web applications have two types of pages: 

  1. pages you can view without being authenticated (front page, landing page, blog post, login, register)
  2. pages you need to be authenticated to view (profile settings, inbox, dashboard)

If you try to view a page of the latter type, you'll usually get redirected to a login page. Here's how to implement that in Django:

Observe how neatly the private views are marked with login_required. While going through the code, it is very clear to the reader which pages require the user to log in and which pages do not.

Conclusions

I hope you had fun learning about decorators because they represent a very neat Python feature. Here are some things to remember:

  • Correctly using and designing decorators can make your code better, cleaner, and more beautiful.
  • Using decorators can help you DRY up your code—move identical code from inside functions to decorators.
  • As you use decorators more, you'll find better, more complex ways to use them.

Remember to check out what we have available for sale and for study on Envato Market, and don't hesitate to ask any questions and provide your valuable feedback using the feed below.

Well, that's that about decorators. Happy decorating!


by George-Bogdan Ivanov via Envato Tuts+ Code

Create an Algorithm Trading Robot: The Basics of Writing An Expert Advisor in MQL4

Wealthsimple.com

The new Wealthsimple.com provides smart investing tools and information via an intuitive, interactive interface.
by via Awwwards - Sites of the day

Is An Agile Java Standard Possible?

This week we had one of the three face-to-face meetings that the JCP executive committee (EC) has each year. This is only my second meeting of this format; despite my long history with Java it’s interesting to see the way things work from this perspective.

Since the minutes of the meeting have not yet been published I won’t talk directly about what was discussed. However, one thing that has been on the minds of the JCP EC for some time is how the standardisation of Java SE will work in the future.

First, let’s look at how things have worked in the past. The JCP was started in 1998, as a formalised mechanism to allow interested parties to develop standard technical specifications for Java technology (thanks, Wikipedia). This was the start of an open process for developing the definition, through standards, of Java platforms, APIs and technologies. Prior to J2SE 1.4, Sun developed Java internally and made all the decisions about what features to add and what changes to make.

The table below shows the history of Java Specification Requests (JSRs) for Java SE including the size of the expert group (EG).

Release

JSR

EG Size

Date

Java 2 SE 1.4

59

8

May, 2002

Java 2 SE 5.0

176

18

September, 2004

Java SE 6

270

19

December, 2006

Java SE 7

336

4 + 2 Oracle

July, 2011

Java SE 8

337

3 + 2 Oracle

March, 2014

Java SE 9

379

3 + 2 Oracle

Early 2017

There are also a couple of odd JSRs in the 900 range that are for maintenance releases of the specifications, specifically for J2SE 1.4. These are JSR 915, 916, 917, 918 and 923. The idea of these seems to have been dropped subsequently.

Continue reading %Is An Agile Java Standard Possible?%


by Simon Ritter via SitePoint

How to Use Facebook to Market Your Products

Do you have products to sell? Have you tried using Facebook ads to promote your products? To find out how to market products via Facebook, I interview Steve Chou. More About This Show The Social Media Marketing podcast is an on-demand talk radio show from Social Media Examiner. It’s designed to help busy marketers and [...]

This post How to Use Facebook to Market Your Products first appeared on .
- Your Guide to the Social Media Jungle


by Michael Stelzner via