Thursday, March 31, 2016

Web Design Trends You Can’t Ignore in 2016 - #infographic

Web Design Stats You Can’t Ignore in 2016 - infographic

Each one of us loves the ease and convenience that digital marketing offers. We often tend to ignore the efforts that businesses and their teams are putting in. One of the most formidable challenges in the field of digital marketing, for companies and their marketers, is to maintain the pace with the speed of advancements launched. Just give it a thought that if the busy marketing teams won’t be able to catch up and miss things due to their involvement in routine activities – how unpleasant would it be for the people who don’t belong to this industry?

If you are also a marketer, you might be facing the same issues. The visitors or end-readers could sympathize with you, but that doesn’t strictly implies they will stop nagging about the significance of surviving through the constraints of time to stay ahead of rise and falls of digital marketing. Not just a single trick or strategy, staying up-to-date with digital trends and unbeatable practices are the actual driving forces for successful, long-term campaigns of marketing.

We all know that the Internet is an aesthetic space where images, graphics and videos play a prominent role in the stories that marketers and companies narrate. But as the accessibility of web design among masses has increased at a progressive rate, it is changing at a faster pace.

Therefore, all the marketers should take a deeper dive into the web design world to identify the most advanced shifts in the traditional practices. Here’re some web design trends that you can’t ignore in 2016 elaborated along with statistical data:

by Guest Author via Digital Information World

10 jQuery Horizontal Scroll Demos & Plugins

In today’s post we bring to you 10 jQuery Horizontal Scroll Demos & Plugins useful for those who see things horizontally. I guess we have to accept some people scroll both ways! :)

Updated: March 2016 Updated all plugins and demos with the latest versions and added some new ones. Also removed plugins which aren't in development anymore.

1. ScrollMagic

Image of a top hat

ScrollMagic helps you to easily react to the user's current scroll position. Its lightweight (6KB gzipped) and mobile friendly. It has support for both scroll directions.

See the demo

2. jInvertScroll

Screenshot of jInvertScroll homepage

jInvertScroll is a lightweight plugin for jQuery that allows you to move in the horizontal with a parallax effect while scrolling down.

See the demo

3. Horizontal Timeline

Mock-up of timeline screen

This tutorial will teach you to create an easy to customise, horizontal timeline powered by CSS and jQuery.

See the demo

4. Smooth Horizontal Scrolling with jQuery

Screenshot of the demo

This tutorial will teach you how to create a simple smooth scrolling effect using the jQuery Easing Plugin and just a few lines of jQuery.

See the demo

5. simplyScroll

Screenshot of a simplyScroll demo

Continue reading %10 jQuery Horizontal Scroll Demos & Plugins%


by Ritesh Kumar via SitePoint

An Introduction to AngularJS Style Guides

What is a style guide? Do AngularJS projects need a style guide, and why? Which are the most popular AngularJS style guides? How would you use a style guide in a team of developers? This article is going to answer all these questions. Before diving into AngularJS style guides, let's look at what a style guide is and why we developers need one.

Why Style Guides

Wikipedia provides a good general definition that can be useful to understand why style guides are important and to get the big picture before diving into AngularJS style guides.

A style guide (or manual of style) is a set of standards for the writing and design of documents, either for general use or for a specific publication, organization, or field. A style guide establishes and enforces style to improve communication. To do that, it ensures consistency within a document and across multiple documents and enforces best practice in usage and in language composition, visual composition, orthography and typography. For academic and technical documents, a guide may also enforce the best practice in ethics (such as authorship, research ethics, and disclosure), pedagogy (such as exposition and clarity), and compliance (technical and regulatory).

Coding style guides enforce the best practice in relation to a particular language and to your organization's needs.

Project Style Guides

There are a number of reasons why JavaScript projects need a style guide. I'm not going to cover all of them in full detail in this article, but they usually expand on the language style guide by covering the following additional topics:

  1. Modularity: single responsibility, immediately invoked function expressions, module dependencies
  2. Application structure: architectural patters, folders structure
  3. Naming conventions: for modules, controllers, configuration and spec files
  4. Linting: JavaScript code checkers
  5. Testing: the approach in writing specs
  6. Comments: to produce documentation
  7. Startup logic: configuration, startup logic
  8. Routing: navigation flow, view composition
  9. Exception Handling: decorators, exception catchers, route errors
  10. Performance and Security: minification, obfuscation

Existing JavaScript Style Guides

For JavaScript there are a number of general and project-specific style guides out there:

Despite the big names, none of the style guides mentioned above is totally comprehensive. In my opinion, the Airbnb style guide is the most up-to-date and comprehensive, and provides also eslint configuration files with which you can automatically check your code style. The eslint configuration files can be extended, as I did when building my web site.

Why AngularJS Projects Need a Style Guide

AngularJS projects need a style guide pretty much for the same reason all JavaScript projects need a style guide, but there are some Angular-specific items that can be covered.

Let's consider the following AngularJS-specific examples:

  • How to use ng tags. AngularJS ng directives can be used in different ways and have a different syntax, for example preferring data-ng instead of ng when using the ng directive as an HTML attribute, in order to be W3C-compliant. Specifying how to write ng directives in a code style guide helps improving consistency in the HTML files.

  • Different ways to implement components. AngularJS implements web components using custom directives. Custom directives can be based on HTML element names, attributes, class names, as well as comments. A style guide might assure that only one type of directive is used within a project for example.

  • Which architectural pattern to adopt. AngularJS allows for MV* (or MVW) architectural patterns. That leaves the choice to JavaScript developers about whether to implement their application based on MVC or MVVM. Guidelines about what kind of approach has to be used in the project helps in keeping the whole team on the same track.

Continue reading %An Introduction to AngularJS Style Guides%


by Francesco Iovine via SitePoint

New Course: JavaScript for Windows 10 Universal Apps

Using Jetpack’s Publicize for Easy WordPress Social Sharing

You’ve just hit publish on your shiny new blog post. It’s packed with information that you know your readers will love. Wouldn’t it be even better if you could click one button and share your new post with your entire online network?

With Jetpack’s Publicize feature, you can instantly share posts on social media networks. So if you’re one of the millions of WordPress users taking advantage of Jetpack’s functionalities, you can use the Publicize feature immediately. You only have to set up your accounts once, and then you can start sharing right away.

Continue reading %Using Jetpack’s Publicize for Easy WordPress Social Sharing%


by Ian Chandler via SitePoint

Robin Mastromarino – Portfolio

Robin Mastromarino UI/UX designer and HETIC student based in Paris.


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

Portfolio of Valentina Pherson

Animating SVGs combined with hand drawn illustrations and clean design.


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

VTB Bank Ukraine

We’ve created architecture and design for corporate website of VTB Bank. One of the hardest parts of this project was development of the structure of the project – taken in count amount of information that needed to be presented.


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

Brueli – Minimal Portfolio / Agency

Brueli is a fully responsive One & Multi page template designed and develop with a minimal design for Portfolio, Agencies, Freelancers and Architects. This HTML5 template is perfect for building an awesome website within minutes.


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

Drupal 8 Entity Validation and Typed Data Demonstration

In the previous article of this series we’ve started our dive into the Entity Validation and Typed Data APIs. We’ve seen how DataType plugins interact with data definitions and how various constraints can be added to the latter at multiple levels and extension points.

Drupal 8 logo

In this part, we will cover the aspect of actual validation and violation handling. In addition, we will write our own constraint and validator so that we can use custom behaviors in the data validation process.

Validation and Violation Handling

Even though we don’t yet know exactly how constraints are built, we’ve seen how they can be added to Typed Data definitions, including entity fields. Let us now see how we can validate the entities and handle possible violations we find.

When talking about Typed Data we’ve already seen how the validate() method can be called on the DataType plugin instance which holds a data definition. When it comes to entities, this can happen both at entity and field levels.

For instance, we can validate the entire entity using the validate() method:

$entity->set('title', 'this is too long of a title');
$violations = $entity->validate();

In our previous article, we added the Length constraint to Node titles to prevent title strings longer than 5 characters. If that is still in place and we run the code above, the validation should obviously fail. The $violations object is now, however, an EntityConstraintViolationListInterface instance which provides some helper methods for accessing violation data specific to Drupal content entities. It’s worth looking into that interface for all the helper methods available.

To get a list of Entity level violations we can use the getEntityViolations() method but we can also loop through all of them. Once we have our individual ConstraintViolationInterface instances, we can inspect them for what went wrong. For instance, we can get the error message with getMessage(), the property path that failed with getPropertyPath() and the invalid value with getInvalidValue(), among other useful things.

When it comes to fields, the property path is in the following format: title.0.value. This includes the field name, the key (delta) of the individual field item in the list and the actual property name. This represents the property path of our violation above.

Apart from calling validation on the entire entity (which may be superfluous at times), we can also do so directly on each field:

$entity->set('title', 'this is too long of a title');
$violations = $entity->get('title')->validate();

In this case, $violations is again an instance of ConstraintViolationListInterface and can be looped over to inspect each violation. This time, though, the property path changes to no longer include the field name: 0.value.

Continue reading %Drupal 8 Entity Validation and Typed Data Demonstration%


by Daniel Sipos via SitePoint

How First-Time Founders Can Develop Sales Skills

Sale!

“As a founder, what must you have to be successful?”

I’ve asked a lot of entrepreneurs this question—22, to be exact. And out of those 22 people, all but four answered:

“Salesmanship.”

At first, this answer surprised me. Wasn’t it more important to have a great idea, or a great team, or a great work ethic? But it started to make sense.

After all, entrepreneurs are constantly selling—they pitch investors, they pitch clients, they pitch potential employees, they pitch influencers and journalists, and so forth.

[author_more]

If you’re just starting out, and you’ve never sold before, check out these four strategies for learning how to sell.

Shadow a Salesperson

Watching a great salesperson work is hugely informative: you'll get insight into their best practices, routines, responses to common questions and objections, and more.

But you shouldn't follow just one salesperson around. As a general rule, shadow one salesperson from every "segment" you'll be approaching.

For example, to learn how to sell to VCs, you should shadow a fellow startup founder. To learn how to sell to journalists, shadow a PR rep. To learn how to sell to your clients, shadow a salesperson in your industry.

You should call upon your network to get these opportunities. But let's say you don't know any PR reps or industry salespeople–in that case, I recommend finding relevant groups on MeetUp and leveraging the contacts you make there. For example, if you've founded a SaaS company, going to a meetup for SaaS entrepreneurs, salespeople, or enthusiasts would give you tons of potential connections.

Once you've identified some people you want to shadow, here's how to frame your request:

Hey name,

I hope you're doing well! I have a semi-unusual request for you: Could I follow you around for a day (or a half-day) while you work? You're an amazing job title, and I'd love to learn how you communicate with clients and leads, talk to investors, pitch to influencers, etc. Lunch on me.

I'd be happy to work with your schedule, but if you're too busy, absolutely no worries.

Thanks,

Your name

If you get a positive response, ask to shadow the person on a day where they've got a variety of tasks and meetings.

Here are a couple things I recommend watching for:

  • What language the person uses
  • How they tailor their approach to the individual lead or client
  • Which communication formats they use (email, phone, Skype, in-person meetings, etc.) and for what purposes (following up, answering questions, explaining the product, introducing themselves, etc.)
  • How they prepare

Once you notice an effective technique or strategy, you can incorporate it into your own sales methods.

Build a Sales Process

Pablo Picasso allegedly said, "Learn the rules so you can break them like an artist."

And this maxim definitely holds true when it comes to selling. Once you've become a more experienced salesperson, you can go rogue.

But up until that point, establishing a sales process will give you consistency and direction—as well as a baseline for tracking your progress.

First, figure out how the typical sales process unfolds. This step will take a couple weeks, at minimum: You'll need to be getting out there and doing lots of outreach so you can gather first-hand data.

Maybe you find that the average customer requires three phone-calls and one face-to-face meeting before deciding to buy. Or that it's much easier to close deals with clients when you've given them a live demo. Or that rather than reaching out to the CEO of the company about your payroll software, you should contact their human resources decision.

Take what's most effective, and create a formal plan. This plan should have distinct stages; so, Stage 1 might be "Establish contact with manager of human resources," whereas Stage 2 could be, "Schedule product consultation."

While it's most important to set up a process for traditional selling, you'll also find it helpful to set up processes for pitching to VCs, the media, and anyone else you're informally selling to.

Continue reading %How First-Time Founders Can Develop Sales Skills%


by Aja Frost via SitePoint

Benjamin Guedj

opl-big

Lovely big typography and big imagery in this beautifully arranged One Pager for French designer, Benjamin Guedj. The transitions between projects is absolutely seamless and I just loved the all-projects view with the zoom-out effect.

by Rob Hope via One Page Love

6 Tips to Get Past a Creative Block

Maybe you’re a graphic designer. Or you’re part of the creative workforce. Or perhaps you simply create on the side. Either way, if you find yourself producing innovative work on the regular, then you’ve definitely come face to face with the dreaded creative block.

So what do you do when you’re hard pressed to come up with anything clever and a deadline is looming? You might squirm, distract yourself with email, or drink an entire bottle of chardonnay hoping for divine inspiration (Ă  la Michelangelo) but that won’t solve the problem. Better to learn some strategies that will help you over the hurdle and get your creative juices flowing again.

1. Nature nurtures (your creative side)

man vs. nature: A man in a wide open cool climate forest valley

Many of us live in cities and suburbs where it might be unrealistic to visit the “great outdoors” on a regular basis. But even if you can’t get to the beach, or the lake, or the mountains it still helps to get out to a park—or out for a walk for some fresh air, and a fresh change of perspective. Evidence points to nature being exceptionally helpful in freeing your creative mind. Green space has a calming effect on your brain, and this helps encourage creative ideas because your brain isn’t distracted by the fast pace of city life. In fact, the effect is increased when you avoid distractions like your smart phone and text messages. Which leads me to topic #2…

2. Kill the Internet!… If only for a few hours.

Laptop in the dark with an almost closed lid

Increasing evidence points to how smartphones, social media, and the internet have created more distractions in our lives, making it harder to concentrate on one task at a time and “killing our creativity.”

Filling your idle time with work emails and getting caught up on texts may feel productive, but the loss of free time can be detrimental to your imagination. Your brain needs time to unwind and be absent-minded in order to formulate fresh ideas. So, if you’re finding it difficult to follow through on the task at hand, do your best to avoid filling that time with status updates, or seeing what new Instagram posts are in your feed. Letting a wandering mind ruminate over an idea is key to sparking the creativity you seek.

3. Lie down. And try not to fall asleep.

[caption id="attachment_127361" align="alignright" width="400"]Illustration: Girl in onesie lying on her tummy. by Jj Duran[/caption]

The creative workforce does a lot of their work while sitting. Or increasingly at standing desks— or even while pedaling! But one doctor’s study has shown that many of our creative ideas actually come to us when we’re lying down. The study tested subject’s abilities to solve anagrams, those tricky word puzzles whose answer usually “reveals” itself to the observer in an “an ‘A-ha!’ or Eureka moment.” This notion may resonate with you, too, if you’ve ever come up with the solution to a tricky creative problem while in bed.

So, you may want to try lying down for a change in perspective when dealing with a creative block. Or, if you don’t want to be the oddball at the office lying under your desk, I suggest keeping your journal, drawing pad, Wacom tablet, musical instrument, or other preferred creative idea generator by your bed, ready for when creativity strikes!

4. Be a kid again!

[caption id="attachment_127355" align="aligncenter" width="900"]Little red riding hood dancing with wolf by Ava N Garda[/caption]

I know you have a job, and deadlines, and a hectic be-everywhere-all-at-once schedule, but it truly helps to turn off the logic of day-to-day thinking once in awhile and play! Playing helps free your creative mind from the reason and rigor of right-brain thought. When you play you’re often suspending critical judgement, and you’re able to approach ideas from a new, novel perspective.

In fact, companies like Google and 3M have also embraced the idea of whimsy in the workplace by creating offices that resemble classrooms and game rooms.

So what things can you do to let your inner kid out? Get out your old legos, or sit on the floor (for a childlike perspective) and doodle. Try learning a new instrument. Or a new language! Join an intramural sports team… Whatever it is, remember that the pleasure of the experience is important. So really, do what’s fun!

Continue reading %6 Tips to Get Past a Creative Block%


by Hilda via SitePoint

Lebowski Agency

Lebowski Agency

Subtle parallax effect in the universe background of this One Pager for Lebowski Agency from Sweden. Really like how they designed the team section names to look like a film poster.

by Rob Hope via One Page Love

How to Use PostCSS with Gulp

PostCSS has been gaining popularity rapidly for some time now. If you have not used it yet or don’t know what PostCSS is, then I suggest you take a look at this introductory PostCSS tutorial, which discusses the basics of PostCSS including how to install and run PostCSS with a quick overview of some plugins.

In this tutorial, I will show you how to use PostCSS with Gulp, the popular automation tool. Since this is not an introductory Gulp tutorial I won’t be covering the basics of Gulp. But for a quick refresher, you can check out this excellent article.

PostCSS website

[author_more]

Setting Up the Project

Before beginning this tutorial, you should have a project folder that you will work in. The folder should have Gulp installed and have two folders inside it with the names “initial” and “final” (or some other name of your choice). The folder called “initial” will have your raw and unprocessed CSS code. The “final” folder will have the processed files, ready to be used.

Before going any further, navigate to your project folder using the terminal and run the following command:

[code language="bash"]
npm install gulp-postcss --save-dev
[/code]

The --save-dev flag adds the plugin that you are installing to the project.json file as a dependency. This will be helpful in situations where you need to collaborate with others on a project. When other team members run the npm install command on your package, all the plugins will be installed automatically.

At this point your folder structure should be:

  • initial — The folder with your raw CSS files.
    • style.css — Unprocessed stylesheet that we will edit later.
  • final — The folder with processed CSS files.
  • node_modules — The folder with all npm modules.
    • gulp — Created when you installed Gulp.
    • gulp-postcss — Created after running the command above.
  • guplfile.js — Your Gulp file.
  • package.json — Your package.json file.

Installing a Plugin

Let’s install a basic plugin to get started. The plugin we are going to use is short-color. This basically extends the existing color property to also set the background color using a second value. Run the following command to install short-color.

[code language="bash"]
npm install postcss-short-color --save-dev
[/code]

You could also install both gulp-postcss and postcss-short-color at the same time using:

[code language="bash"]
npm install gulp-postcss postcss-short-color --save-dev
[/code]

After both plugins have been installed, you need to open up and edit the gulpfile.js file so you can start working with the plugin. We begin by including the following lines to enable both plugins:

[code language="javascript"]
var gulp = require('gulp');
var postcss = require('gulp-postcss');
var shortColor = require('postcss-short-color');
[/code]

Now, let’s set up a Gulp task to process our raw CSS file and create a production-ready stylesheet. Here is the code to do so:

Continue reading %How to Use PostCSS with Gulp%


by Nitish Kumar via SitePoint

Ruby Interview Questions: LRU Cache and Binary Trees

As we talked about last time around, most interview problems for software engineering positions across the industry concern algorithms and data structures. With a bit of practice, it is possible and reasonably enjoyable to tackle these problems in Ruby. We have covered some of the basics: linked lists and hash tables. This time, we'll go a bit deeper. We'll implement an LRU cache (and explain what that is) and also look into binary trees, all in Ruby.

Continue reading %Ruby Interview Questions: LRU Cache and Binary Trees%


by Dhaivat Pandya via SitePoint

AntiPatterns Basics: Rails Views

In this beginner-friendly series, we’re looking at AntiPatterns, which—as the name implies—represent pretty much the opposite of design patterns. They are discoveries of solutions to problems that you should definitely avoid.

In this article we’ll focus on the main View AntiPattern—PHPitis—and work through a couple of techniques to keep your views lean and mean. Having tons of Ruby code in your views is not only nasty but often plain unnecessary.

Topics

  • Rails Views
  • PHPitis
  • Extracting Helpers
  • Helpful Helpers
  • Forms
  • Partials
  • Conditional Content
  • Semantic Markup

Rails Views

Rails comes with ERb (Embedded Ruby) out of the box, and I think it’s not necessary to throw in cool view-rendering engines like Slim for our examples for now. If you think “convention over configuration” mostly applies to the model and controller layers, you are missing out on a lot of the goodies that make working with Rails so speedy and progressive. Taking good care of the view layer includes not only the way you compose your markup but also CSS/Sass, JavaScript, view helpers, and your layout templates. Viewed from that angle, it becomes a bit deeper than you might think at first. The sheer number of technologies which can be involved in creating your views suggests that care should be taken to keep things neat, clear and flexible.

Since the way we write markup and styles is a lot less constrained than domain modeling, you want to be extra cautious to keep things as simple as possible. Maintenance should be pretty much your number one priority. Since redesigns or design iterations can be more frequent than extensive changes to your model layer, preparing for change gets a whole new meaning when it comes to your user-facing layer. My advice: don’t necessarily build for the future, but also, by all means, do not underestimate the rate of change—especially if you have one of those “idea guys” who knows jack about implementations on the team. What I like about Rails’s approach towards views in MVC is that it is treated as equally important, and the lessons learned from the model domain were incorporated into the view—whenever possible and useful. Other frameworks seem to agree, since they integrated a lot of these ideas pioneered by Rails.

Since the last article was a bit more extensive, I chose this topic as a small breather. The following articles about Rails controllers and testing are again bigger in size. The AntiPatterns for views are not that many, but they are nevertheless equally important. We’ll focus on the main one, PHPitis, and work through a couple of techniques to keep your views lean and mean. Since the view is your presentation layer, maybe you should be especially careful to not create a hazardous mess. Let’s get to it!

PHPitis

Why do we have MVC in the first place? Yes, because the separation of concerns seemed like the most reasonable thing to do. Sure, the implementations of this idea vary a bit here and there, but the overall concept of having distinct responsibilities for each layer is the core motivation for building robust applications. Having tons of code in your view layer might not be alien to developers coming from the PHP side of things—although I hear their frameworks have caught up already (heavily influenced by things like Rails?)—but in Ruby-land these things have long been a loudly voiced AntiPattern.

The obvious problems like mixing responsibilities and duplications aside, it simply feels nasty and lazy—a little stupid too, to be frank. Sure, I get it, when you develop much within a framework, language or whatever ecosystem, it’s easy to become complicit or numb towards things like that. What I like about the people pushing Ruby is that these things seem to have a lot less weight—that might be a reason why innovating never seemed to be a problem within the community. Whatever works best wins the argument, and we can move forward.

So is this a whole section dedicated to bashing PHP? Not at all! In the past, PHP apps had the reputation of having weak separations between models, views and controllers (maybe this was one of the core reasons why people felt writing apps with Rails was much more appealing). Having single files with code for all three layers didn’t seem that sexy. So when we stuff tons of Ruby or domain code into our views, it starts to look like the dreaded PHP style of structuring things—PHPitis. Only a few things are as bad as this when it comes to developing web apps, I feel. When you care about happy developers and your own future sanity, I can’t see why anyone would go down that road—there’s only pain ahead, it seems.

Rails offers a lot of goodies to minimize code in the view as much as possible. You must learn the ways of helpers, layouts and preprocessors in order to achieve a cleaner view. A simple rule of thumb is to keep domain logic out of your views—no shortcuts!

The price to pay for being lazy on this is hard to overestimate. The Ruby code that must be in the presentation layer should be as little and as simple as possible, as well as intelligently organized. Your reward will be code that is a joy to extend and to maintain, and new team members will also have an easier time wrapping their heads around the new codebase. As a bonus, neat freak designers who code also won’t be angry and hide rotten food in your salad if you keep tons of Ruby code out of their markup.

Helpful Helpers

Knowing the myriad of helper methods in Rails will significantly improve the quality of your presentation layer. Not only will it clean things up and inject the occasional speed boost in productivity, but more importantly it helps you fight PHPitis.

The thing that you should appreciate about these helpers is that they represent extractions from commonly needed code. Instead of reinventing the wheel, when in doubt, check if there isn’t already a helper around that solves your issue in the view—the same goes for Models and Controllers as well, of course.

Here’s a list of helpers you should look into pretty much right away:

  • form_for
  • Other helpers for forms.
  • fields_for
  • link_to
  • content_for
  • And writing your very own, of course.

Forms

Let’s have a look at form_for first. I know forms are a little bit boring and not that sexy for a topic, but I highly encourage you to read up on them to familiarize yourself with the finer details. It’s important to understand how they work. I remember often just glancing over them without giving them much attention. Sure, you can get them to work quite easily without understanding what’s going on under the hood. In the future, I might take the time to write a complete article on them. In the meantime, I highly recommend that you spend a little time checking the documentation–at least you‘ll appreciate how convenient Rails makes it to deal with form stuff.

The Ugly

The example below shows you the HTML of a little form we need for creating agents. It only accepts three parameters as input: name, number and licence_to_kill. A lot of code for this little task, actually. The authenticity_token comes from Rails–it’s a security thing that protects the app from “cross-site request forgery”.

some.html.erb

Writing a form by hand is not only lengthy but error prone as well. Also, if we approached it that way, we’d also have to solve the issue with the varying routes and CSS classes that we might need for creating a new object and updating an existing one—in effect, we would need to duplicate forms to create and edit records. As you’ll see soon, Rails meets you more than halfway on that. Verdict: however you put it, the manual approach is nasty and lacks convenience.

The Bad

We could go down the following road, which does not make perfect use of conventions in Rails. Heads up, don’t do it. It basically shows that you’re not handling the available tools to your advantage and you are duplicating the form for new and edit actions.

some.html.erb

What happens here is that the form builder carries the model you need for the form.

Behind the scenes, the line above gets expanded into the following:

The form_for method takes a couple of arguments:

  • a symbol or a string for specifying the object
  • a url hash
  • an html hash
  • a namespace hash

The url hash is for specifying the routing options. That means that you can manually specify to which routing path you submit the form—named routes come in handy with this. This style is called the “generic way” because you need to manually configure the form_for call.

Why is this solution suboptimal? Because we want to keep business logic out of our Views and Controllers as much as we can. A side effect of that is that we need to change fewer parts when needed.

HTML

In case you missed it, this approach did not provide us with ids and classes for the form tag automatically. The ones for input tags, however, were generated for you. We’ll fix that in a minute. Just know what you can get for free and that you probably should use this to your advantage. If you need something different or an additional namespace, you can use the html hash or the namespace hash to specify things a bit more.

some.html.erb
HTML

Not bad! Now the form tag has the specified class and id—whatever makes your blood flow—and the input tags are namespaced with mi6. Almost there.

The Good

This one is called the “resource-oriented style” and has the least amount of Ruby you need to write in your views. With that approach, we want to rely on automated resource identification. Rails figures out which routes it needs based on the object itself. Not only that, it gives you a different HTML output for creating a new object or for editing an existing one. Behind the scenes, Rails just asks the object if it already exists and acts accordingly.

Creating forms this way is a clever use of conventions and helps avoid duplication. One line and all the heavy lifting is done for you.

some.html.erb

Much better, isn’t it? Now we get exactly what we need for both existing and new objects. Also, we didn’t need to add text to our submit button. Rails took care of that and also adapts to new or existing objects.

HTML for a New Object
HTML for Editing Objects

When editing objects, it is also reflected in the HTML output by adding the id to the form id and the route or action needed for updating a specific object.

A word about Rails magic. When people argue in exactly these situations that Rails is too magical for their taste, I often think that this could simply mean that they haven’t spent enough time learning the tools of their trade. Once you take the time to master these tools, you’ll often understand why a simplification or extraction was made, and they also appear a lot more sober and straightforward.

Attention!

The code examples above used form_object as a block parameter. This is not recommended best practice but was done to remind you what this object represents and what gets yielded from form_for. Most people just use a plain |f| or |form|, which looks much nicer and more concise.

By the way, things like label, text_field, check_box and the like are just helper methods that are called on the form builder object. There are a ton of them which cover pretty much any possible need you might encounter.

some.html.erb

Concise and reads nice, right?

Partials

Collections are another thing we don’t want to be too verbose about. Rendering partials for individual objects of collections is so concise and straightforward—if done right—that I feel you have very little excuse for not making use of Rails conventions to reduce Ruby view code.

Let’s turn things around with this one and start with an example that shows you how you are encouraged to approach this. Along the way, I’ll explain what you can leave out as well.

The Good

app/views/agents/index.html.erb

The render method is quite smart. The line above is all you need to write for iterating over a collection. If you need to change something in this view, it will be a very small change—and therefore a small cause of error.

What happens here is that the framework is able to determine which partial it needs. Through the name of the object, it knows where to look for the partial—given that you adhere to the conventional naming of things. The way I see it, this is a good example of how Rails is not trying to impress you with wizardry. The Rails team works hard to make your life easier by cutting through repetitive red tape of sorts.

app/views/agents/_agent.erb

The only other thing that is necessary to make this work is to place a partial template at the appropriate path in your object’s directory and extract the attributes you need from the object. No need to write any loops on your own. It’s fast and easy, handy and pragmatic, I’d say.

This extraction was originally done because the name of the partial was most of the time the name of the iterated object anyway, and so it was easy to create a convention that handles this common task more effectively.

The Bad

OK, now that we know how to handle this, let’s look what you could and should avoid. The example below is just a bad usage of Rails, but I wouldn’t call it ugly this time.

app/views/agents/index.html.erb

You get the same result as above, but it’s definitely more verbose. Iterating over the collection in the view is not necessary anymore. When you use render as above, the block parameter agent is implied, and you can just use it without the each loop. So stay away from code like this—it does not make you look particularly good (but nobody will collect your head for it either). It’s just not elegant and adds to the PHPitis.

Extracting Helpers

The most obvious solution for cleaning up code from your views is to avoid writing any or to extract them intelligently. Let’s say we want to scramble the names of our agents in the index list. We should not put this code directly in our views. If we decide that the model is also not the appropriate layer to place this, then a custom helper in the app/helpers directory might be the right choice.

app/helpers/agents_helper.rb

By packaging this in a module inside the helpers directory, we now have access to this method in our views. Please give specific helpers their own home, and don’t put everything on ApplicationHelper (app/helpers/application_helper.rb), which is really meant for more “global” stuff.

Now I can access this little fellow in my partial template—or any view—for rendering my collection of agents.

app/views/agents/_agent.erb

Your own custom helpers are a great way to keep your views clean and healthy. And as you have seen, it’s so quick and easy that there’s little excuse to be too lazy and not extract them for battling PHPitis.

Conditional Content

The helper method content_for is a handy tool for extracting content that doesn’t really fit the bill for a partial but needs a bit of encapsulation. It’s a way to store a bit of markup that you can apply on a page-per-page basis—you yield it into the layout where needed. In size, it should be a lot smaller than partials or even layouts.

This technique can also save you the step of creating your own method for it. Navigational menus or sidebars are often examples where this helper becomes useful. Let’s say you want to have a spot in your menu that is only for admins, but you don’t need to adjust the whole layout. Or you have pages where the sidebar is not needed. With content_for, you inject what you need where you need it on a page-per-page basis. Duplication no more!

app/views/agents/index.html.erb
app/views/layouts/application.html.erb

Aside from the fact that this header is a good candidate for extraction into a partial, look at the yield :double_o_navbar section. This is a yielding region that inserts code from a content_for block. It will only insert code if the symbol names match. Here we want only double-o agents to have access to certain links in the navbar. Everyone else sees just Home and About. Think about the special links an admin needs to see that should never face a public interface.

You can also use this helper to insert id or class attributes on HTML tags if needed. Every once in a while this comes in handy.

Another common use is populating the <title> of a page dynamically with a content_for block.

app/views/layouts/application.html.erb
some.html.erb

You just place the title you want in a content_for block and the application layout will insert it for you. You can get more clever with it, but that should suffice for now. Should you have no need for a title or forget to add one, then the logical || will kick in and yield a default of your choice. In the example above, we need to check for the presence of a title or the default won’t work.

What you definitely don’t want to do is create instance variables for that kind of thing. Single responsibilities, remember?

One more thing: you can ask if pages have a content_for block.

app/views/layouts/application.html.erb

This can help you avoid duplicating markup that is relevant to styling a page which adapts if elements are present on a page or not.

Semantic Markup

This is stuff you definitely want to avoid.

The markup above is from the bootstrap documentation and specifies how the columns are supposed to ‘look’—information that has no semantic meaning and actually belongs in your stylesheets. That’s the stuff designers have nightmares about.

So what’s the deal with that? This is important because—besides the questionable naming of classes—unsemantic markup violates separation of concerns. Your markup should not be bothered with styling information; instead, both should stand on their own and enable you to switch out styles effortlessly—without touching your HTML. It’s not as difficult as it might sound at first. It takes a bit of discipline, though.

When you are able to keep that styling information out of your markup, you have effectively reduced PHPitis on another front—for designers an essential one! Also, the use of generic divs without inherent meaning is another example of poor markup. HTML5 gives you lots of useful elements that convey more information to your future self, other developers, and search engines. Naming is supposedly hard, but HTML5 provides you with lots of semantic elements that make your options much easier in that regard.

Final Thoughts

I hope you have seen that Rails Views don’t need much love to shine. Developers can be a bit snobby about the front-end layer. Dealing with markup sometimes seems to be a little beneath them—writing HTML, DUH! Well, I shouldn’t throw any stones, but I came to appreciate a fine-tuned, well-honed presentation layer. It makes it much more fun to work with and, when done right, much faster to make the inevitable changes. Parsing tons of Ruby code mixed with badly written markup is not a fun experience in my book.


by Ed Wassermann via Envato Tuts+ Code

Hey, It’s Your Six-Figure Salary Calling

Hey, it’s your six-figure salary calling

If you’re looking to move to a job that offers stability and a often a six-figure salary, look no further than the industry with one million job openings in 2016, according to a Cisco report. Cyber security is the place to be—and we’ve got a deal that’ll help you get there. Get the Cyber Security Hacker & Penetration Testing Certification Training for $39.

This training helps you dive right into cyber security and penetration testing, with 117 classes and 20+ hours of content covered security code, web-based vulnerabilities, cross-site request forgery, and all the other essentials hiring managers want to make sure you’re familiar with. You’ll get lifetime access to the video lessons, exercises, quizzes, and assessments, and there’s even a discussion forum if you get stuck.

You dream job awaits. Get the Cyber Security Hacker & Penetration Testing Certification Training for $39.

Continue reading %Hey, It’s Your Six-Figure Salary Calling%


by SitePoint Offers via SitePoint

What Is Joomla?

Such is its popularity and usefulness over the last decade that Joomla! is considered one of the top-ranked open-source CMSs across the globe at the moment. Since its inception from the Mambo CMS, over the last ten plus years, it has improved so much that it’s no wonder that there are plenty of awards in its kitty already and still counting.

Specifically, if you’re in the field of web development, no matter the technology you’re dealing with, it’s impossible to get away from the word Joomla! If it’s so, I’m sure that you belong to some other planet! It may sound a bit overwhelming, but I can assure you that it’s something more than worth looking at if you haven’t done that yet for your next content management solution. In fact, it’s more than just a CMS—we’ll discuss later in this article what Joomla! is capable of.

In this article, we’ll thoroughly discuss what Joomla! is and how it could be useful for your web-based projects. Starting with a glimpse of the basic CMS, we’ll go through the features of Joomla! throughout the article, and in the last section I’ll leave you with some useful resources with references.

What Is a CMS?

A content management system, referred to as a CMS, is a system that allows you to manage information easily and effectively. The information could be anything, whether it’s a simple article or a complex media management system. The goal of a CMS is to provide an effective workflow which depicts the clear state of an entity at any given point in time. In simple terms, it allows information to pass through different states like draft, review, editing and publish.

Specifically, it’s non-technical users who love to have such a system at their disposal that allows them organize content easily and makes the whole process joyful rather than hectic. In any web-based application, there are three basic operations, which most of the time the administrators find themselves doing, performed on any given entity—add, edit and delete. And that’s what a CMS is designed for. Whether it allows you to do that by providing a WYSIWYG editor, inline editing or some other fancy goodies, the idea is to make the whole process effortless.

It’s not just the organization and management of content, but how good it is at providing granular access control to different groups of users, that's considered as one of the premium features of any CMS. It’s obvious that you would like to split up the responsibilities across different roles like author, editor and publisher. The provision of content versioning is also something you would like to keep your eyes on as it allows you roll back articles if things don’t go as expected.

In its most basic form, the typical workflow of any CMS could be something like:

  • The author starts a conversation by creating an article, and the default status of an article is draft at this point in time. Usually, it takes a couple of iterations for an article to get switched from draft to review status.
  • The Reviewer is granted permission to access all the articles having status set to review. Again, it takes a conscious effort from the reviewer to go through them and forward them to editors if they meet certain guidelines that are a must for an article to switch from review to editing status. Of course, the reviewer could send them back to draft status by leaving appropriate comments if an improvement is expected from the author.
  • Going through all the articles in editing status and beautifying them with final touches is something expected from the Editor in their day-to-day routine. Also, they are responsible for pushing content from editing to the publish queue.
  • Finally, it's the job of the Publisher to make sure that the content sitting in the publish queue gets the proper treatment by scheduling their publishing in the front-end.

Generally speaking, what we've listed above is one of the most simple yet effective use-cases one could adhere to. Not to mention that in the real world you'll witness more complex workflows accompanied with rich features like tagging, social sharing, and commenting, to name a few.

So, that's a quick and hopefully useful introduction of what a CMS system could look like. From the next section onwards, we'll focus on the main subject of this article, Joomla!, which is something I promised we'll explore throughout this article.

Joomla!—an Award-Winning CMS

Since its inception back in 2005, Joomla! has evolved over the years, and the end result is one of the most powerful and feature-rich CMSs, downloaded by millions of users. As they say, it's truly a community-based CMS, run by and for the community! For any open-source project, as with Joomla!, the support from community members is an important factor in the persistence and sustainability of the project.

Joomla! is built using some of the most widely used web technologies like PHP, MySQL and Apache. Having said that, it's not just limited to the aforementioned technologies—it also supports other popular databases and web servers. You could choose from either SQL Server or PostgreSQL instead of MySQL database engine if you prefer to do so. On the other hand, Microsoft IIS and NGINX are candidates for the choice of web server along with Apache.

For developers, Joomla! is built using the MVC design pattern, a popular pattern used by plenty of other frameworks already. Although discussion of the MVC design pattern is something out of the scope of this tutorial, it provides a separation of concerns, thus allowing the developer to concentrate more on development rather than worrying about how it would look in the front-end.

It's no surprise that the latest major version of Joomla! is responsive out-of-the-box and mobile-first, as it's impossible nowadays to ignore that, and it could be costly for any framework that did so. As of writing this, Joomla! 3.4.x supports PHP 5.5+ version but not PHP 7. However, the release of the much-awaited version Joomla! 3.5 is around the corner, and it claims to support PHP 7, which will be a huge performance boost natively, if experts are to be believed.

So, if that was a high-level overview of what Joomla! is all about, the following list highlights some of the concrete features you've been waiting for, which ship with the Joomla! core itself.

  • out-of-the-box content management features
  • content organization using nested level of categories
  • content versioning and tagging
  • media management
  • user management
  • powerful ACL (Access Control Lists) system
  • smart search feature for site wide free-text search
  • RSS Feeds
  • multilingual features
  • responsive and mobile-friendly interface

Of course, it's impossible to discuss each and every feature in detail in a single article, so for those curious users I'll leave some useful resources at the end of this article.

Joomla!—Beyond the CMS World

You’re on the wrong side of the table if you believe that Joomla! is only useful for content management, as you’ll be surprised to hear that there are more than 7,000 extensions available on the official JED (Joomla Extensions Directory) site, providing features that range from a simple image gallery solution to a full-fledged booking and reservation management system. In fact, there is a strong possibility that the extension you’re looking to develop on your own is already available on the JED!

The extensible architecture of Joomla! makes custom extension development a breeze. Are you looking for a system that serves as a blog? Maybe your new venture requires that you build a new YouTube kind of system, or you’re trying to build the next Facebook! The JED provides extensions for each of the aforementioned requirements.

Let’s have a glimpse of the luxury you could have if you choose Joomla! as your solution:

  • a full-fledged media management system
  • e-commerce solutions
  • portals with community features like social sharing, commenting, tagging and the like
  • online reservation and booking systems
  • classifieds solutions
  • event calendar and RSVP kind of systems
  • business directories
  • educational and government websites
  • portfolio systems

That’s just to name a few, as it’s very difficult to list each and every possibility. As they say, the limitation is your imagination—so true for Joomla!

Joomla! as a Web Framework

In day-to-day Joomla! development, there are times when you feel that you would have wanted to pull a certain part of the framework, the routing API for example, rather than a whole bunch of CMS features that are obsolete for that particular project. For a simple PHP-based application, it would be nice to have those selected features from the framework that are most suited to your application, rather than a whole CMS.

For example, say you want to build a service that exposes Joomla! data to a third-party mobile application. To achieve that, it's completely fine to make a custom extension that fulfills the desired functionality, but with the additional baggage of those unwanted CMS features in your case. Instead, what you would have loved to do is to select the APIs of your need by avoiding the rest of the features, and the end product is a super-light web application.

That's the purpose of Joomla! Framework, earlier known as Joomla! Platform. It allows you to build an application using a familiar set of APIs, if you're coming from the Joomla! CMS background. It provides a common set of APIs, as with the other PHP frameworks, allowing you to concentrate more on the application-specific features rather than reinventing the wheel for features like input handling, database abstraction layer, routing and the like.

It's by no means to be confused with the Joomla! CMS, as there's a separate line of development for both pieces of software. The main idea is to decouple the software packages into separate modules, rather than tying them into a single package, allowing them to evolve on their own. In fact, you could think of the Joomla! CMS as a combination of the Joomla! Framework and CMS modules.

One promising example of the Joomla! Framework is the Issue Tracker application of the Joomla! CMS itself. In the same way, you could build any web application with it that you would have built with any other PHP-based framework. Explore it and I'm sure there's something it has to offer for everyone.

Joomla!—a Quick Glance at the Major Elements

In this section, we'll discuss the important elements of the Joomla! architecture that serve as basic building blocks in any application.

Components

This is one of the most important and a must-have element in the stack that provides the complete functionality of any specific section. It allows you to create a base that deals with the business logic of an application. Also, it's one of the elements that extends Joomla!, should you like to introduce any new features.

For example, if you want to build a business directory application, one should be able to add, edit and delete the entries from the back-end. On the other hand, in the front-end it should display a nice listing along with advanced search, pager and sorting features. So it's the component you would like to build to wrap the aforementioned functionality.

As a rule of thumb, whenever you want to build any new functionality in Joomla!, it's the component that comes to the rescue.

Modules

Before I go ahead and explain what a module is in Joomla!, I would like to give you a couple of examples to make things easier. If you've ever visited Joomla! front-end, you'll see lots of blocks like Login, Latest Articles, Latest Feeds, etc. To your surprise, they are Joomla! modules assigned to different positions in the template! A Joomla! module is a movable block that builds the output by fetching the data from the component, most of the time, and displays the output.

Plugins

More often than not you’ll need to change the core framework behavior to fulfill your custom needs, and that’s where plugins come into the picture. A Joomla! plugin allows you to catch certain system-defined events, opening the door for customization of some of the important workflows.

As an example, say you would like to notify a third-party application in the event of new user registration on your website. Of course, there’s a provision to alter the data that transits back and forth between the event calls.

Templates

As the name suggests, it deals with the presentation layer of your website and helps structure your website layout. Sometimes, it’s also referred as a Joomla! theme as it allows you to change the look and feel of your website. To change the default look of the Joomla! core, you need to make a custom theme as per the Joomla! theme structure, and that’s something you’ll come across frequently if you’re a Joomla! developer.

Not to mention that the latest version of Joomla! comes with a responsive theme in the front-end and back-end. Also, it’s something expected from theme designers as well during the course of custom theme development.

What Is the Joomla! Extensions Directory (JED)?

The JED is something that you should make yourself familiar with, as you'll probably spend quite a bit of time there searching for an extension for your purpose. It's an official Joomla! site that offers plenty of extensions to choose from in the form of components, modules and plugins.

Extensions at JED are released under two kinds of license—free and commercial. As you may have guessed, the commercial extensions are paid goodies, available either on a subscription model or by paying a one-time fee. As a developer, it's an area you would like to get the benefit of, by developing quality extensions and releasing those under commercial license.

In fact, most of the time it works in this way: the free version of an extension is available with basic features, and the paid version of the same extension is boosted with power features, in the form of add-ons in some cases. Not to mention that the luxury of technical support from the extension service provider comes with the commercial version. Hence, it's a successful and proven business model for many commercial extension providers.

Having said that, I won't take any credit away from those quality free extensions that serve the purpose as well as any paid extension. In fact, it's a set of strict standards and rules each extension has to go through that makes sure that the extensions listed on JED meet the desired quality standards.

So, that's the JED at your disposal—make yourself comfortable with it and you'll be glad you did that.

Where Should I Start?

For first-time users, it’s always recommended to install Joomla! on your local system and explore the features in the front-end and back-end to get yourself used to the system. Here are some important resources for newbies:

For experienced PHP developers:

It’s such a wide subject that you’ll find plenty of online tutorials and videos at your disposal. Also, the members of Joomla! community forum are friendly enough to help you sort out any issues.

Conclusion

It was my pleasure to introduce one of the most popular open-source CMSs in the field of web development—Joomla! Although we’ve barely scratched the surface of the Joomla! world, I hope that I was able to do justice to the subject.

Starting with an introduction to CMSs, we’ve gone through the different aspects of Joomla!, followed by a discussion of important architectural elements. We also looked at the JED, and I provided some useful resources in the later part of this article.

Don’t hesitate to see what we have available for sale and for study in the marketplace, and don't hesitate to ask any queries and provide your valuable feedback using the feed below.


by Sajal Soni via Envato Tuts+ Code

How to Build a Peer Network to Increase Your Social Reach

gm-social-sharing-network-560

Does the content you share get the reach it needs? Want to learn how to get your content seen by more people? A network of social advocates will help you amplify the reach of the content you share. In this article you’ll discover how to build a network of peers and fans that will help [...]

This post How to Build a Peer Network to Increase Your Social Reach first appeared on .
- Your Guide to the Social Media Jungle


by Greg Miller via

Floppi

Floppi

Vibrant launching soon page with playful illustrations for an upcoming design collaboration tool called 'Floppi'.

by Rob Hope via One Page Love

Filip Nordin

Portfolio of Filip Nordin
by via Awwwards - Sites of the day

Wednesday, March 30, 2016

Detectr.js : JS Library to write Clever CSS Selectors

This plugin is a very small javascript library which gives you the ability to write clever and specific CSS rules to refine your website design for each different browser, platform, device and operating system.

The post Detectr.js : JS Library to write Clever CSS Selectors appeared first on jQuery Rain.


by Admin via jQuery Rain

TempGauge : jQuery Temperature styled Gauge plugin

Mini jQuery Temperature styled Gauge plugin, that replaces Temperature Values with an Temperature Gauge.

Features:

  • Replaces temperature values with a Temperature Gauge canvas
  • Show Temperature Label
  • Set Gauge Border Color
  • Set Gauge Fill Color
  • Set Max and Min Temperature
  • Set canvas width (height is calculated width * 2)
  • Gauge-plugin is chainable

The post TempGauge : jQuery Temperature styled Gauge plugin appeared first on jQuery Rain.


by Admin via jQuery Rain

Create an Alexa Skill and Get Three Months Free on Envato Tuts+

How to Build a Trivia Game for Amazon Echo in Under an Hour

5 #ContentMarketing Strategies to Increase Blog Traffic

5 Content Marketing Tactics to Increase Blog Traffic

Why is blog traffic important? Because most buyers these days make up their minds on whether to purchase a product or contract a service by reading your blog, finding out new information on which they base their new, researched purchase.

A statistic in DemandGen’s 2015 content marketing survey report shows that over 75% of B2B (business to business) purchasers base their decisions on content the use for research.

Have you ever wondered how many posts get published each day? Over 1 milion posts! Yes, that’s right! Just take a look at this amazing blogging statistics meter from worldometers.info.

Now you’re thinking: “With so many blog posts being published each day in the world, how can I make mine stand out?” That’s good because that’s exactly what I aim to help you wit in this article.

Not so long ago bloggers would have the mentality that if they would write quality articles, people will naturally find them and bring their blog lot of traffic. I am sorry to say it, but things just don’t work that way.

In order to really bring value to your readers with your articles, you have to first reach your audience; your content needs to be easily found by your target audience.

by Mike Dane via Digital Information World

Get 1,200+ Design Elements for $19

Get 1,200+ design elements for $19

Whether you're creating marketing materials for a client, working on your comic book side project, or designing your own greeting cards, we've got something that'll save you a ton of time on any design project. Get the Mega Graphics Bundle for $19 at SitePoint Shop.

This valuable bundle usually goes for $1,325, so don't miss your chance to grab it for 98% off. You'll get 1,260 elements, all with an Extended License so you can use them again and again. Create greeting cards with the hundreds of love patterns and holiday elements. Choose from dozens of logo designs for your small business. Dress up fliers, business cards, and posters with colorful backgrounds and nature and weather elements. And work on your comic book with dozens of comic book elements and speech bubbles.

Save 98% on the Mega Graphics Bundle. Get it for $19 at SitePoint Shop.

Continue reading %Get 1,200+ Design Elements for $19%


by SitePoint Offers via SitePoint

Building a Filtering Component with CSS Animations & jQuery

Some months ago, I wrote an article about MixItUp, a popular jQuery plugin for filtering and sorting. In today’s article, I’ll show you how to build your own simple filterable component with jQuery and CSS animations.

Without further ado, let’s get started!

Setting Up the HTML

As a first step, I’ll show you the HTML structure of the component. Consider the following markup:

[code language="html"]
<div class="cta filter">
<a class="all active" data-filter="all" href="#">Show All</a>
<a class="green" data-filter="green" href="#">Show Green Boxes</a>
<a class="blue" data-filter="blue" href="#">Show Blue Boxes</a>
<a class="red" data-filter="red" href="#">Show Red Boxes</a>
</div>

<div class="boxes">
<a class="red" data-category="red" href="#">Box1</a>
<a class="green" data-category="green" href="#">Box2</a>
<a class="blue" data-category="blue" href="#">Box3</a>

<!-- other anchor/boxes here ... -->

</div>
[/code]

Notice that I’ve set up some pretty basic markup. Here’s an explanation of it:

  • First, I’ve defined the filter buttons and the elements that I want to filter (we’ll call them target elements).
  • Next, I’ve grouped the target elements into three categories (blue, green, and red) and I gave them the data-category attribute. The value of this attribute determines the category that each element belongs to.
  • I’ve also assigned the data-filter attribute to the filter buttons. The value of this attribute specifies the desired filter category. For instance, the button with the data-filter="red" attribute/value will only show the elements that belong to the red category. On the other hand, the button with data-filter="all" will show all the elements.

Now that you’ve had an overview of the required HTML, we can move on to explore the CSS.

Setting Up the CSS

Each time a filter category is active, its corresponding filter button receives the active class. By default, the button with the data-filter="all" attribute gets this class.

Box with active class

Here are the associated styles:

[code language="css"]
.filter a {
position: relative;
}

.filter a.active:before {
content: '';
position: absolute;
left: 0;
top: 0;
display: inline-block;
width: 0;
height: 0;
border-style: solid;
border-width: 15px 15px 0 0;
border-color: #333 transparent transparent transparent;
}
[/code]

In addition, I’m going to use flexbox to create the layout for the target elements.

Using flexbox for the layout

See the related styles below:

[code language="css"]
.boxes {
display: flex;
flex-wrap: wrap;
}

.boxes a {
width: 23%;
border: 2px solid #333;
margin: 0 1% 20px 1%;
line-height: 60px;
}
[/code]

Lastly, I’m defining two different CSS keyframe animations that I’ll use later on to reveal the elements:

[code language="css"]
@keyframes zoom-in {
0% {
transform: scale(.1);
}
100% {
transform: none;
}
}

@keyframes rotate-right {
0% {
transform: translate(-100%) rotate(-100deg);
}
100% {
transform: none;
}
}

.is-animated {
animation: .6s zoom-in;
// animation: .6s rotate-right;
}
[/code]

With the markup and CSS in place, we can start building the JavaScript/jQuery.

Continue reading %Building a Filtering Component with CSS Animations & jQuery%


by George Martsoukos via SitePoint

Quick Tip: Understanding the Yield Keyword in Python

When we call a function in Python, the function will normally start working until it encounters a return, exception, or reaches its end – after which it returns control back to the caller. Whenever you call that function again, the process will start from scratch!

Say that you asked a person to track the red cars on the road. The person will keep getting a question asking them if they spotted a red car or not, and the person in turn would answer with either ‘yes’ or ‘no’. If the person answered ‘yes’, the number of times the red car was spotted will increase.

Let’s see how we can do this in Python:

import time

def red_cars(answer):
    n = 0
    while True:
        if answer == 'yes':
            n = n + 1
            return n
        else:
            return n

stop = time.time() + 5 * 60
while time.time() < stop:
    answer = raw_input('Did you spot a red car on the road? ("yes" or "no"): ')
    times = red_cars(answer)
    print 'You have spotted ' + str(times) + ' cars so far!'

If you run the program, what do you notice? Did you notice that the number of times for the ‘yes’ answer is always capped at 1, and when you answer ‘no’ the number of times gets 0 regardless of answering ‘yes’ before?

Here is where Python’s yield keyword comes into play. yield is a means by which we temporarily hand control to the caller, and expect to continue from the point at which control has been handed over.

Before giving the solution to the above example, let me demonstrate a very simple example to better illustrate how yield works.

Say we have the following simple Python script:

def step_by_step():
    return 'step 1'
    return 'step 2'
    return 'step 3'
    
step = step_by_step()
for i in range (3):
    print step

If you run the script, you will get the following output:

step 1
step 1
step 1

Now, if we use yield instead, as follows:

def step_by_step():
    yield 'step 1'
    yield 'step 2'
    yield 'step 3'
    
step = step_by_step()
for i in range (3):
    print step.next()

The output would be as follows:


step 1
step 2
step 3

As you can see, we were able to create a series of values, as for each call the function continues from the point where it yields a value. This type of function is called a generator. Such function creates a generator iterator, as with each call to the method next() we move to the next yield statement.

If we come back to our main example (red cars), it can be written as follows to perform the required task:

import time

def red_cars(answer = None):
    n = 0
    while True:
        if answer=="yes":
            n = n + 1
            answer = yield n
        else:
            answer = yield n

car_color = red_cars()
car_color.next()

stop = time.time() + 5 * 60
while time.time() < stop:
    answer = raw_input('Did you spot a red car on the road? ("yes" or "no"): ')
    print 'You have spotted ' + str(car_color.send(answer)) + ' cars so far!'

Thus, as we can see, yield is deemed important when we are interested in resuming execution at the last point where the function (generator) exited, and where we are also interested in keeping the values of local variables between the different calls – unlike normal functions, where such values are destroyed when exiting the function.

Continue reading %Quick Tip: Understanding the Yield Keyword in Python%


by A. Hasan via SitePoint

4 Things I Wish I’d Been Told at the Start of My Freelance Career

I’ve been freelancing for around 5 years now... full time for the last 3. I enjoy the freedom, the high pay I’ve been able to achieve, and perhaps most importantly, the diversity of activities.

[author_more]

Of course, you can’t do something for 5 years without learning a few things, so I wanted to take a moment today to share a few of the things I wish I’d known back at the beginning. I’ll also mention a few things I managed to avoid that seem to be common tripping points for many freelancers.

I hope that’s enough intro for you, because we’re diving right in.

1. Pricing Has Nothing to Do with Service Quality

A lot of people tend to think that price is directly related to quality. Sure, you know of some exceptions, but on average, people to tend to earn what they’re worth, right?

No. Not with freelancing. In fact, you need to completely get out of that mentality if you want to make real money as a freelancer.

The reality of capitalism is that pricing has nothing to do with quality. Pricing is 100% determined by what people are willing to pay. As a freelancer, my service cost is based entirely on what I can negotiate from a client as opposed to the actual value of my work.

If you want to make more money as a freelancer, you don’t need a better service, you need better negotiating skills. Here’s the cliffnotes for making that happen:

How to Negotiate Higher Pay

Quality is important, of course, and we’ll talk about that next, but it has virtually nothing to do with your pricing. I’ve made $12 and $800 for essentially the exact same article. If you can change your mentality and understand that price is a matter of how much your client is willing to pay, you can immediately begin making more money for the exact same amount of work.

2. Your Long-term Success Will Depend Entirely on Quality

While the quality of your work will not determine how much you earn on any given project, it WILL determine how many projects you get from repeat and referred clients, which tend to make up the bulk of a successful freelancer’s income.

Don’t let this detract from my previous point. You can do $800 quality work and get paid $12 the rest of your life if you fail to grasp point #1.

If, however, you are successfully charging $800 for $12 quality work, you will typically find yourself failing to attract recurring business. There are always exceptions, of course, and if you are in a market where clients tend to have limited understanding of the service provided, you might be able to get away with scamming. But honestly, if your goal is simply to rob people, becoming a freelance service provider is a horribly inefficient way to accomplish that.

The best way to succeed over the long haul is to provide consistent value to everyone you work with. When a client comes away thrilled with your work, there’s a fantastic chance that will turn into additional work and a referral or two down the road. When this happens with EVERY client you work with, you are essentially building a passive lead-generation network.

Focus on doing quality work and continue to improve as your career progresses. This is THE best way to achieve long-term success as a freelancer.

Continue reading %4 Things I Wish I’d Been Told at the Start of My Freelance Career%


by Jacob McMillen via SitePoint