Friday, January 20, 2017

The Complete Facebook Image Sizes And Dimensions Guide (2017) - #infographic

Facebook allows you to target your audience with razor sharp precision. Whether you’re looking to attract new clientele, create brand awareness or simply grow your online presence, you can design posts that appeal to your audience by age, location and interests easily if you have the right visual...

[ 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

How to Earn Passive Income by Creating Digital Info Products

Wouldn't it be nice to have a way to make more money without working 60 hours a week? Or to have something to offer to people whose budget is too low for your services right now, but who really like your style?

If you're willing to put in a little extra effort up front, information products can be a huge help when it comes to both of these issues--and they can go a long way when it comes to evening out the ups and downs of freelance income.

Why create an info product?

First off, for the sake of this article, an info product means something like an instructional ebook or a "how to" video--as opposed to a software product. Obviously, building software requires a lot more work than creating a user guide. An info product takes less time for you to create but still provides value for your customers.

Continue reading %How to Earn Passive Income by Creating Digital Info Products%


by Michelle Nickolaisen via SitePoint

Laravel and Braintree: Middleware and Other Advanced Concepts

Previously, we saw how to configure a Laravel app to handle Braintree subscriptions.

Braintree Logo

This time, we'll talk about how to:

  • Prevent users from signing up to the same plan twice
  • Add basic flash messaging to our application
  • Add the ability to swap plans
  • Create middleware to protect some routes based on the subscription status
  • Restrict users with basic subscriptions from accessing premium content
  • Cancel and resume subscriptions
  • Add Braintree notifications to the application's events via webhooks

Double Subscriptions

As it stands, if we visit the plans index page, we can still see the Choose Plan button for the plan we are currently subscribed to, and this shouldn't be the case. In the plans index view. let's add an if conditional to hide the button based on the user's subscription status:

[...]
@if (!Auth::user()->subscribedToPlan($plan->braintree_plan, 'main'))
    <a href="" class="btn btn-default pull-right">Choose Plan</a>
@endif
[...]

But that's not to say users can't access the plan by typing in the URL pointing to the same plan in the address bar. To counter this, let's update the code in the show action of the PlansController to this:

[...]
public function show(Request $request, Plan $plan)
{
    if ($request->user()->subscribedToPlan($plan->braintree_plan, 'main')) {
        return redirect('home')->with('error', 'Unauthorised operation');
    }

    return view('plans.show')->with(['plan' => $plan]);
}
[...]

Here, we are getting the user from the request object; remember all our routes fall under the auth middleware and thus it's possible to get the authenticated user. Once we get the user, we check if they are already subscribed to the plan. If that's the case, we redirect them to the homepage and display a notification. We will implement basic flash messaging later.

One last precaution is preventing users from submitting the payment form with a different plan ID value. It's possible to inspect the DOM element and change the value for the hidden input. In our SubscriptionsController, let's update the store method to this:

[...]
public function store(Request $request)
{
    $plan = Plan::findOrFail($request->plan);

    if ($request->user()->subscribedToPlan($plan->braintree_plan, 'main')) {
        return redirect('home')->with('error', 'Unauthorised operation');
    }

    $request->user()->newSubscription('main', $plan->braintree_plan)->create($request->payment_method_nonce);

    // redirect to home after a successful subscription
    return redirect('home')->with('success', 'Subscribed to '.$plan->braintree_plan.' successfully');
}
[...]

Flash Messaging

Let's now implement some basic flash messaging to display notifications in the app in response certain operations. In the resources/views/layouts/app.blade.php file, let's insert this block right above our content since flash messages show up at the top before any other content:

Continue reading %Laravel and Braintree: Middleware and Other Advanced Concepts%


by Christopher Vundi via SitePoint

Erlang and Elixir, Part 3: Functions

Elixir is built on Erlang, and in both Erlang and Elixir a function is not just identified by its name, but by its name and arity.  Remember: Everything in Elixir is an expression.

To give you a clear example of this, below we have four functions, but all defined with different arity.

To provide a concise way to work with data, we can use guard expressions like so:

Guard expressions such as when is_binary(a) allow us to check for the correct type before performing an operation. 

Unlike Erlang, Elixir allows for default values in its functions via usage of the \\ syntax like so:

Anonymous Functions

In the previous part, we discussed anonymous functions briefly as a data type. To elaborate on this further, take this example:

We see this powerful shorthand here on the first line fn(a, b) -> a + b end. With this we are able to produce a basic operation sum.(4, 3) and get the output in just two lines of code. 

Now, looking to the square method, fn(x) -> x * x end, can it really be any simpler? Working now with the map, we can perform the square anonymous function over the whole map—again in just two lines of code!

Pattern Matching 

Arithmetic is all fun and good, but let's see what we can do with text. 

Here, with pattern matching we can define several outcomes in our control flow, again in hardly any code. Elixir's syntax is rapid to work with and mightily powerful, as we will see in the next example.

First-Class Functions

The anonymous functions we just covered are first-class values. This means that they can be passed as arguments to other functions and also can serve as a return value themselves. There is a special syntax to work with named functions in the same way:

Here we define a Math module with defmodule and define the square function. Then we can use this in conjunction with the map method demonstrated earlier and the Math module we just defined. We use the same operator &, allowing us to pass our function Math.square/1 to capture the square function's output for each entry in our list. 

That's a whole lot of power for just one line. This is referred to as a partial function capture in Elixir.

Control Flow

We use the constructs if and case to control flow in Elixir. Like everything in Elixir, if and case are expressions.

For pattern matching, we use case:

And for comparison logic, we use if:

For ease of use, Elixir also provides an if function that resembles many other languages and is useful when you need to check if one clause is true or false:

Dynamic Functions

This is possible in Elixir via usage of the unquote method mentioned earlier. For example, to check some hard-coded Admins in our system, we can do the following:

Here we have created the methods Admins.check_manager and Admins.check_super from the atom names.  

Conclusion

Everything is an expression in Elixir, and that means we can get a whole heap of power out of writing very little code. 

For me, Elixir looks similar to CoffeeScript, Ruby, Python or any minimalist syntax as the form is so direct and to the point, but Elixir is far more powerful than these languages due to the meta-programming aspect. 

Going forward, we will see how to utilise control flow and functions more to create interactivity in our app.


by Tom Whitbread via Envato Tuts+ Code

Nicholas Ruggeri - Portfolio

I'm Nicholas, an Italian guy living in Italy, where I work as a frontend developer.
by via Awwwards - Sites of the day

Scrum Rituals: Sprint Demo

The following is an extract from our book, Scrum: Novice to Ninja, written by M. David Green. Copies are sold in stores worldwide, or you can buy it in ebook form here. At the end of the sprint, everything that was worked on for the current sprint is demonstrated for the team, the product owner, […]

Continue reading %Scrum Rituals: Sprint Demo%


by M. David Green via SitePoint

getlorem – Library to Generate Lorem Ipsum Text

getlorem is a library for generating passages of Lorem Ipsum text, suitable for use as placeholder text in documents. This library can also be used as a jQuery plugin.


by via jQuery-Plugins.net RSS Feed