Wednesday, February 17, 2016

Get a $147 Design Assets Bundle for Free

Get a $147 design assets bundle for free

Having a great collection of stock photos, icons, and vectors on hand is a must for designers who want to save time and take their projects to the next level in seconds. Start building your collection of ready-to-go design assets—or add to it—with BundleStorm’s collection of assets. Normally $147, the whole collection is completely free for SitePoint readers.

Get a $147 design assets bundle for free

Grab this free bundle and get thousands of icons, stock photos, hand-drawn vectors, Photoshop patterns, Illustrator symbols, badges, banners, and more. Whether you’re creating a sleek website, designing playful cards, or putting together a professional presentation, you’ll find plenty to choose from among the many styles available.

Did we mention they’re all free? Grab the free BundleStorm design asset bundle at SitePoint Shop.

Continue reading %Get a $147 Design Assets Bundle for Free%


by SitePoint Offers via SitePoint

7 Simple Speed Solutions for MongoDB

MongoDB is a fast NoSQL database. Unfortunately, it is not a cure for all your performance woes and a single complex query can bring your code grinding to a halt. I recently suffered this fate and it can be difficult to know where to look when your application suddenly becomes unstable. I hope these tips help you avoid the pain I went through!

1. Check Your MongoDB Log

By default, MongoDB records all queries which take longer than 100 milliseconds. Its location is defined in your configuration's systemLog.path setting and it's normally /var/log/mongodb/mongod.log in Debian-based distributions such as Ubuntu.

The log file can be large so you may want to clear it before profiling. From the mongo command-line console, enter:

[code]
use admin;
db.runCommand({ logRotate : 1 });
[/code]

A new log file will be started and the old data will be available in a file named with the back-up date and time. You can delete the back-up or move it elsewhere for further analysis.

It can also be useful to watch the log while users are accessing your system, e.g.

[code]
tail -f /var/log/mongodb/mongod.log
[/code]

Continue reading %7 Simple Speed Solutions for MongoDB%


by Craig Buckler via SitePoint

An Introduction to Reasonably Pure Functional Programming

When learning to program you're first introduced to procedural programming; this is where you control a machine by feeding it a sequential list of commands. After you have an understanding of a few language fundamentals like variables, assignment, functions and objects you can cobble together a program that achieves what you set out for it do - and you feel like an absolute wizard.

The process of becoming a better programmer is all about gaining a greater ability to control the programs you write and finding the simplest solution that's both correct and the most readable. As you become a better programmer you'll write smaller functions, achieve better re-use of your code, write tests for your code and you'll gain confidence that the programs you write will continue to do as you intend. No one enjoys finding and fixing bugs in code, so becoming a better programmer is also about avoiding certain things that are error-prone. Learning what to avoid comes through experience or heeding the advice of those more experienced, like Douglas Crockford famously explains in JavaScript: The Good Parts.

Functional programming gives us ways to lower the complexity of our programs by reducing them into their simplest forms: functions that behave like pure mathematical functions. Learning the principles of functional programming is a great addition to your skill set and will help you write simpler programs with fewer bugs.

The key concepts of functional programming are pure functions, immutable values, composition and taming side-effects.

Pure Functions

A pure function is a function that, given the same input, will always return the same output and does not have any observable side effect.

// pure
function add(a, b) {
  return a + b;
}

This function is pure. It doesn't depend on or change any state outside of the function and it will always return the same output value for the same input.

// impure
var minimum = 21;
var checkAge = function(age) {
  return age >= minimum; // if minimum is changed we're cactus
};

This function is impure as it relies on external mutable state outside of the function.

If we move this variable inside of the function it becomes pure and we can be certain that our function will correctly check our age every time.

// pure
var checkAge = function(age) {
  var minimum = 21;
  return age >= minimum;
};

Pure functions have no side-effects. Here are a few important ones to keep in mind:

  • Accessing system state outside of the function
  • Mutating objects passed as arguments
  • Making a HTTP call
  • Obtaining user input
  • Querying the DOM

Controlled Mutation

You need to be aware of Mutator methods on Arrays and Objects which change the underling objects, an example of this is the difference between Array's splice and slice methods.

// impure, splice mutates the array
var firstThree = function(arr) {
  return arr.splice(0,3); // arr may never be the same again
};

// pure, slice returns a new array
var firstThree = function(arr) {
  return arr.slice(0,3);
};

If we avoid mutating methods on objects passed to our functions our program becomes easier to reason about, we can reasonably expect our functions not to be switching things out from under us.

let items = ['a','b','c'];
let newItems = pure(items);
// I expect items to be ['a','b','c']

Benefits of Pure Functions

Pure functions have a few benefits over their impure counterparts:

  • More easily testable as their sole responsibility is to map input -> output
  • Results are cacheable as the same input always yields the same output
  • Self documenting as the function's dependencies are explicit
  • Easier to work with as you don't need to worry about side-effects

Because the results of pure functions are cacheable we can memoize them so expensive operations are only performed the first time the functions are called. For example, memoizing the results of searching a large index would yield big performance improvements on re-runs.

Unreasonably Pure Functional Programming

Reducing our programs down to pure functions can drastically reduce the complexity of our programs. However, our functional programs can also end up requiring Rain Man's assistance to comprehend if we push functional abstraction too far.

import _ from 'ramda';
import $ from 'jquery';

var Impure = {
  getJSON: _.curry(function(callback, url) {
    $.getJSON(url, callback);
  }),

  setHtml: _.curry(function(sel, html) {
    $(sel).html(html);
  })
};

var img = function (url) {
  return $('<img />', { src: url });
};

var url = function (t) {
  return 'http://ift.tt/1jjjbRY' +
    t + '&format=json&jsoncallback=?';
};

var mediaUrl = _.compose(_.prop('m'), _.prop('media'));
var mediaToImg = _.compose(img, mediaUrl);
var images = _.compose(_.map(mediaToImg), _.prop('items'));
var renderImages = _.compose(Impure.setHtml("body"), images);
var app = _.compose(Impure.getJSON(renderImages), url);
app("cats");

Take a minute to digest the code above.

Unless you have a background in functional programming these abstractions (curry, excessive use of compose and prop) are really difficult to follow, as is the flow of execution. The code below is easier to understand and to modify, it also much more clearly describes the program than the purely functional approach above and it's less code.

Continue reading %An Introduction to Reasonably Pure Functional Programming%


by Mark Brown via SitePoint

The Top 5 Responsive Social Sharing Plugins for WordPress

More and more people are accessing the web through their mobile devices each day. Developing responsive pages is fairly standard now, but if you want to go responsive you’ll have to go all in.

Visitors that share your posts and pages are responsible for increasing traffic to your site. Why not make it easier for them to share your content on their social profiles by introducing responsive social sharing feature?

Social sharing plugins are all over the WordPress Plugin Directory and narrowing down a few that go well with your site can be difficult. In this article, we’ll evaluate the top 5 responsive social sharing plugins in depth and highlight the standout features for each.

The Need for Responsive Social Sharing Plugins

The highest rated social sharing plugins in the WordPress Plugin Directory are responsive, since it’s important for web developers and webmasters to integrate responsive design elements into their site to increase user experience.

Non-responsive social sharing buttons (or non-responsive anything for that matter) will end up destroying the appearance, elegance and usability of your site as soon as it’s accessed from a mobile device. Interference with the page’s layout is the least of your problems; chances are that the social sharing buttons will stop responding, shrink to small sizes or slow your site down.

Continue reading %The Top 5 Responsive Social Sharing Plugins for WordPress%


by Rafay Saeed Ansari via SitePoint

This Week's HTML5 and Browser Technology News (Issue 227)


Read this e-mail on the Web
HTML 5 Weekly
Issue 227 — February 17, 2016
Georgie Luhur
A thorough introduction to ARIA (Accessible Rich Internet Applications), an approach to making your sites more accessible to people with disabilities.


Rémi Parmentier
Involves using the CSS calc() function and the width, min-width and max-width properties. It even seems to work with Gmail.


Rachel Andrew
A practical and thorough look at the basics of HTTP/2 as they apply to web designers and developers.


Frontend Masters  Sponsored
With v2, Ember is more performant and complete than ever. In this course we’ll build a rich cross-device app together step-by-step from scratch.

Frontend Masters

Jake Archibald
Chrome is intending to change the behavior of normal stylesheet loading (via ‘link’) so only rendering of content located after the ‘link’ element is blocked. This has key performance implications.


Nick Desaulniers
A slidedeck that walks through all of the basic principles behind WebGL and 3D graphics. Both a good refresher or great primer before you read other material.


Chris Ashton
A developer from the BBC’s Visual Journalism unit explains how to work out a solid cross-browser testing strategy.


Jobs

  • Senior Frontend Developer at bonifyMake a dent in the Fintech universe. How? Join our vibrant international team and be responsible for a unique user experience. See what we can offer you. Bonify
  • Stop Applying to Jobs - Let Companies Apply to YouOn Hired, sign up in 10 minutes and get offers from top companies like Facebook, Uber, & Stripe. Engineers get an average of 5 offers on the platform in 1 week. Try it today. Hired.com

In brief

Curated by Peter Cooper and published by Cooper Press.
Want to post a job? E-mail us or use our self-serve system.

Unsubscribe : Change email address : Read this issue on the Web

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


by via HTML5 Weekly

Jatex

Jatex

Quality product imagery and nice subtle load transitions as you scroll through this One Pager for Jatex - manufacturers of Orthopedic Precision Instruments. Good to know it's built on WordPress too!

by Rob Hope via One Page Love

A Jade Tutorial for Beginners

Jade is an elegant templating engine, primary used for server-side templating in NodeJS. In plain words, Jade gives you a powerful new way to write markup, with a number of advantages over plain HTML.

For example, take a look at this movie card in HTML:

[code language="html"]
<div>
<h1>Ocean's Eleven</h1>
<ul>
<li>Comedy</li>
<li>Thriller</li>
</ul>
<p>Danny Ocean and his eleven accomplices plan to rob
three Las Vegas casinos simultaneously.</p>
</div>
[/code]

This is what the same markup looks like in Jade:

[code language="jade"]
div
h1 Ocean's Eleven
ul
li Comedy
li Thriller
p.
Danny Ocean and his eleven accomplices plan to rob
three Las Vegas casinos simultaneously.
[/code]

The Jade version is elegant and concise. But it's not just about the beautiful syntax. Jade has some really neat features, allowing you to write modular and reusable markup. Before we get into these powerful features, let's do a quick overview of the basics.

[author_more]

The Basics

I’m going to highlight three basic features in Jade

  • Simple tags
  • Adding attributes to the tags
  • Blocks of text

If you want to try this out as we go along, you can use CodePen and choose Jade as your HTML preprocessor or use the online compiler on the official Jade page to compile your Jade to HTML.

Simple Tags

As you might have noticed earlier, there are no “closing” tags in Jade. Instead, Jade uses indentation (i.e. white space) to determine how tags are nested.

[code language="jade"]
div
p Hello!
p World!
[/code]

In the example above, since the paragraph tags are indented, they will end up inside the div tag. Simple!

[code language="html"]
<div>
<p>Hello!</p>
<p>World!</p>
</div>
[/code]

Jade compiles this accurately by treating the first word on each line as a tag, while subsequent words on that line are treated as text inside the tag.

View this example on CodePen

Attributes

All this is great, but how do we add attributes to our tags? Quite simple really. Let’s go back to our first example and toss in some classes and a poster image.

[code language="jade"]
div(class="movie-card", id="oceans-11")
h1(class="movie-title") Ocean's 11
img(src="/img/oceans-11.png", class="movie-poster")
ul(class="genre-list")
li Comedy
li Thriller
[/code]

Pretty neat right?

[code language="html"]
<div class="movie-card" id="oceans-11">
<h1 class="movie-title">Ocean's 11</h1>
<img src="/img/oceans-11.png" class="movie-poster">
<ul class="genre-list">
<li>Comedy</li>
<li>Thriller</li>
</ul>
</div>
[/code]

View this example on CodePen

Continue reading %A Jade Tutorial for Beginners%


by Sanjay Guruprasad via SitePoint