Javascript News

Syndicate content
Pipes Output
Updated: 48 weeks 6 days ago

How to Liven up Your Flat Design with Dirty Dots

Do, 2015-10-01 07:16

About five years ago there was a glorious but bloodthirsty revolution in web design — and like all revolutions, there were winners and losers.

[caption id="attachment_116228" align="alignright" width="380"] Losers and winners[/caption]

The losers were bevelled edges, faux stitched borders, glossy reflections and drop shadows.

The winner was ‘flat design’.

Microsoft got the flat ball rolling with Metro and then successive version of Android and IOS got flatter and visually simpler. Eventually, Material Design distilled it all down into a cohesive theory.

And on the whole, we’re all much better off for it. Graphics files are lighter and faster, and UI’s are simpler and less cluttered. But you could argue there is a certain clinical ‘samey-ness’ to a lot of design 2015.

So, it’s always nice to have methods to give design projects (logos, illustrations, UIs, etc) some warmth and without piling on tonnes of extra visual clutter?

Grab your Retro Spectacles

Print is a technology that has been constantly refined for over 400 years as paper, inks and machinery have improved. The fidelity of high-end print today is incredible.

Funny thing is, we still seemed to be charmed of many of the little failings of those original, low-tech print methods. The kind of throwaway design we've all seen on soup tins, old newspapers and train station walls.

Say Hello to Mr. Retro

[caption id="attachment_116229" align="alignright" width="380"] Mr Retro's Permanent Press filters[/caption]

Photoshop Plugin maker Mr Retro has made a living out of riffing on old print styles with their Permanent Press set of filters. Each filter mimics some of the natural, grungy imperfections of classic printing press work.

These imperfections include:

  • Paper grain
  • Chunky halftone dots
  • Plate misalignments
  • Ink overlap & bleed

These filters are all very configurable and can add a surprising amount of warmth to a flat-color designs without necessarily adding a lot more clutter — especially if used sparingly.

However, at $99 they aren’t cheap. But there are other less expensive ways to squeeze some of the flatness out of a design.

Halftones in Adobe Illustrator

[caption id="attachment_116233" align="aligncenter" width="800"] Illustration: The Future of the Hamburger Menu Icon?[/caption]

This is an illustration I did for an article called ‘Are users ready for the desktop hamburger icon?’ I wanted to keep the image simple but felt it was a touch clinical.

Continue reading %How to Liven up Your Flat Design with Dirty Dots%

Creating PDFs from Markdown with Pandoc and LaTeX

Mi, 2015-09-30 22:00

If you've read some of my previous posts on SitePoint or elsewhere, you may know that I'm working on a board game. In the game, called Chip Shop, you get to run a computer company in 1980s America.

As part of the project, I'm attempting to open source the entire game as much as possible. After several false starts, I've decided on a basic framework of Markdown for most of the game components—especially cards and the manual.

As the game's website uses Jekyll, the website for the game is generated from the Markdown files. I intend to have premium pre-boxed and print-yourself versions of the game, and to achieve this I need to generate PDFs from the Markdown files.

What I'm Trying to Accomplish

My ideal workflow is to generate the PDF files at the same time as generating the website, rather than generate the files as visitors request them. This rules out my usual option for PDF generation, wkhtmltopdf, as it generates PDFs from already generated HTML. Another reason it's not an option is that I want the PDF card versions to look different from the HTML pages, and Jekyll lacks any kind of view mode feature to accomplish this without resorting to complex CSS rules.

The Markdown template file for cards in the Chip Shop game contains a lot of Markdown front matter fields for game mechanics. Not all are used on every card. For convenience during printing, I need to fit as many cards on an A4 page as possible—in this case, a 3x3 grid. Eventually the pages will need to be double-sided, but I haven't implemented that yet.

Enter Pandoc and LaTeX

[author_more]

Any internet search looking for solutions to generating PDFs from Markdown will lead you down the Pandoc path. Pandoc is an open-source, Swiss Army knife markup conversion tool that supports a wide and growing variety of input and output markup formats.

To generate PDFs with Pandoc, LaTeX is needed. LaTeX has its roots in the scientific research community, and is a document declaration and layout system. Combining Pandoc and LaTeX allows us to use variables, and thus to generate PDFs from a series of Markdown files and support Markdown front matter.

Despite the power of Pandoc and LaTeX, I couldn't find any way of combining multiple PDFs (cards) onto one page, especially when using variables from Markdown files. After much research, I settled on PDFJam, a simple command line tool for this requirement.

Installing Dependencies Markdown

You need no extra software for Markdown, except maybe an editor and there are so many of those, I suggest you read a few SitePoint posts to make your choice.

Jekyll

I'll continue to use Jekyll in my examples taken from my game to illustrate the build process, but it isn't an essential part of PDF generation if you don't need a website.

Pandoc

On my Mac, I installed Pandoc with Homebrew, but there are options for all operating systems.

LaTeX

There are lots of opinions on the best way to install LaTeX, depending on what you need or intend to do with it. A full installation of its common tools and libraries can near 2GB, but for most purposes a minimal installation will be enough. Read the project's download page to find the best option for you.

For this tutorial, we'll be using the xelatex engine, as I use custom fonts. But you can select any engine that supplies specific features you require.

PDFJam

Depending on how you installed LaTeX, you may have PDFJam installed already. (Check by typing which pdfjam in the terminal.) If you haven't, then find details on installation here.

Continue reading %Creating PDFs from Markdown with Pandoc and LaTeX%

React Data Fetching with Relay

Mi, 2015-09-30 20:00

React is ushering a new era in front end. Published by Facebook, it has rapidly become a popular library used in production by many technology companies. In this article, we’re going to discuss a new complementary React framework called Relay.

The Problem With Data Fetching In React

As React has grown in popularity, the scale and complexity of the projects built with React has grown along with it. React is primarily a view layer library. This has caused some teams to hit unknown territory or limitations while building projects that require a different infrastructure. Facebook has been proactive in offering support and guidance during these growing pains.

Flux

One of the early growing pains for developers using React was event handling. Facebook responded to this issue by publishing Flux, which is an abstract pattern that encouraged unidirectional data flow for handling events in React.

I’ll assume some familiarity with Flux, so I won’t discuss the details of it in this article. In case you aren’t familiar with this topic, you can give a reading to this article by Sandeep Panda or take a look at this page about Flux.

Flux has taken the React ecosystem to the next level. As developers started to get more familiar with Flux, some issues emerged. Flux has been great for managing data as application state, but populating the initial state into an application has been a source of friction.

Continue reading %React Data Fetching with Relay%

PHP Channel’s 3rd 2015 Trimester Update

Mi, 2015-09-30 16:00

Another three months have gone by, and we’ve got some news to share.

First, let’s introduce our newest authors!

New Authors

Jeff Smith, USA

Jeff Smith is a full-stack web developer who enjoys writing and reading of all types, and is interested in the Internet, business and entrepreneurship, technology, and learning new stuff. Jeff has been a very active member of our forums for a while now, and decided to chime in with his opinions by writing about defensive programming in PHP.

His debut post was well received, and part two is coming soon. In fact, it’s already in our peer review queue, so if you’d like to take an early look and give us your opinion on it, our doors are wide open!

Continue reading %PHP Channel’s 3rd 2015 Trimester Update%

How to Write a Winning Pitch Deck

Mi, 2015-09-30 15:43

It’s tough enough to get a meeting with a VC. But once you’ve stolen their attention, how do you get their financial support?

VCs look for the valuable product, great team and exciting mission trifecta. But even if you have those three things, you’re not guaranteed to score an investment—you also need a compelling pitch deck that sums those elements up and makes it very clear to investors why this is one opportunity they shouldn’t pass up.

Wondering how to create a pitch deck worthy of your startup? Read on for tips from VCs, founders and Silicon Valley insiders.

Continue reading %How to Write a Winning Pitch Deck%

Developing in the Cloud: an Introduction

Di, 2015-09-29 22:00

Every web developer needs to set up a development environment—a set of tools to work with, such as

  • a code editor
  • a version control system (such as Git or SVN)
  • build tools and/or package managers
  • DevOps and provision tools (Docker, Puppet, Ansible, Vagrant)

… and so on. Having a good setup is crucial for maximizing productivity.

Development stacks vary from developer to developer, and can depend a lot on a developer's field of work. However, there are some pretty typical setups. SitePoint has recently published examples of local development environments for Linux, Windows and Mac.

In this article, I'll take a look at a fourth kind of development environment—one that's based wholly in the cloud. This will normally happen through a third party service, and there are quite a few to choose from—such as Cloud9, Codenvy and Nitrous.

Advantages of Developing in the Cloud

When using a cloud development environment, you're actually a client of a development platform as a service (dPaaS)—which offers a lot more than just an online code editor.

Faster setup
Firstly, developing in the cloud reduces the setup time. Usually you can use your framework of choice, or use boilerplate code structured as it should be, and all that is done by only clicking some buttons.

Access from Anywhere
You can code from any computer, as long as you have an internet connection—whether you're using the latest iMac, an old Netbook or even a tablet.

Remote Pairing
One of the features I love about these environments is remote pair programming. Cloud IDEs allow more than one developer to access the source code at the same time. You can see each other write code, test and chat in real time.

Multiple Installs
I recently had a problem with a Scala application. The dependencies just wouldn't install. It turned out to be because I had Java 8 installed, while some of the dependencies required Java 7. I did't want to downgrade, since it would probably affect other applications, so I decided to go on with a Vagrant config. Well, if you're in the cloud, you don't have to do that. You can require a container for each application you develop, and the container will be just like you want it to be (Java 7 in this case).

Continue reading %Developing in the Cloud: an Introduction%

Better Password Masking in Your WordPress Forms

Di, 2015-09-29 19:00

Password masking is a technique used by developers to prevent someone from reading the password on the screen while the user is typing the password. However, password masking ends up causing many problems when it comes to the user experience. In this article, we will outline some of these issues caused by password masking and also some solutions.

In particular, we will focus on the user experience problems relating to password masking on the WordPress admin login and password reset forms. We will also create a WordPress plugin which adds a checkbox to the login and password reset forms to show or hide text in a masked password field.

[author_more]

What Is Password Masking?

Password masking is a practice of obscuring all the characters of a password field. This is done to prevent someone from reading the password on the screen while the user is typing it.

Here is how a masked password field looks:

However, in practice this can cause usability problems in many modern computing devices which have either smaller keys for typing are using touch screens.

Continue reading %Better Password Masking in Your WordPress Forms%

Watch: Performance with requestAnimationFrame

Di, 2015-09-29 17:30

Animation in JavaScript can be difficult to create, and even harder to optimize for performance. Learn how to get better at both with requestAnimationFrame! The screencast demonstration can be found in Codepen. You can find the mentioned link from the screencast here: http://html5hub.com/request-animation-frame-for-better-performance/

This is the first video of the series JS with Performance in Mind.

Loading the player...

Continue reading %Watch: Performance with requestAnimationFrame%

Communicating between iOS Apps and WatchKit Extensions

Di, 2015-09-29 17:00

Apple Watch applications that need data updates like stocks, weather, sports and transport information introduce communication methods between the parent iOS application and the WatchKit extension.

In this article I’ll show how to create this communication and introduce real-time messaging between them.

Continue reading %Communicating between iOS Apps and WatchKit Extensions%

The Maker’s Guide to an Unlimited Supply of Customers

Di, 2015-09-29 16:00

Getting customers is no walk in the park; in fact, it’s more like a walk through hell.

“The toughest part of working for yourself isn’t the actual work,” as Paul Jarvis reminds us. “It’s the stuff that enables you DO your work, like business, marketing and sales.”

This is a chronic problem for makers. One that usually leads to people giving up on whatever it is they were trying to build.

What if you had an unlimited supply of customers that didn’t require you blogging, cold emailing or doing any other crap you hate to land clients?

Continue reading %The Maker’s Guide to an Unlimited Supply of Customers%

Are Users Ready for the Desktop Hamburger Icon?

Di, 2015-09-29 15:00

You know the old saying ‘brevity is the soul of wit.’?

It seems that saying is evolving, and brevity is also the soul of the web. As a UX designer, I am always looking for ways of simplifying things, and using shorthand indicators when it makes sense to do so.

When mobile browsing made us rethink how we can simplify user experience within the constraints of minimal screen sizes, the “hamburger” icon was put to the test. Whether or not you believe another icon, shape or even text would do a better job, those three little horizontal lines seem to have won the menu icon arms race.

Originally, the hamburger icon was born out of pure necessity. A desktop-style fixed navigation bar didn’t make much sense on a phone screen. So we started using hidden menus and indicators together, allowing the hidden to become visible. More and more mobile sites got on board with the icon, even before it was widely recognized as the universal symbol for "menu."

Now practically everyone browses on mobile devices. Practically all mobile websites use the hamburger icon. Voilá! Near-worldwide recognition. Now we are put in an interesting conundrum: If everyone universally recognizes the hamburger’s meaning, can we jailbreak it from mobile and set it free onto our desktops? Or more to the point, will users accept it?

Let’s examine the arguments for and against the hamburger on desktop, and ultimately see where it is likely to work best, and where to avoid it altogether.

The Good The "clean factor"

For designer/developers, the main draw for using the hamburger icon in a desktop application is the "clean factor." Minimalist design continues to gain popularity, so of course the impulse would be to strip away everything but the most basic elements.

Navigation is traditionally the workhorse of a website, not adding much in the way of visual flair (in most cases.) If we could swap out something cumbersome and obtrusive with something minimal yet recognizable, the overall effect would undoubtedly be much simpler.

But let’s be careful not to confuse visual simplicity with functional simplicity. More on that later.

Let your CTA be the hero

One of the biggest jobs any UX professional faces is creating a hierarchy that makes sense. We must place more emphasis on certain elements just to make them stand out. But when we scale something up, unfortunately, other elements must end up being minimized.

Hiding the navigation elements away behind a hamburger icon is a great way to call more attention to whatever action you want the end user to take. As an example, in a simple portfolio site, the ultimate action you want from your users is to hire you. So, if your landing page has enough information for them to go on, it isn’t unrealistic to expect them to click your CTA directly from that page. The goal is to highlight your main CTA button, since the other menu items are probably secondary anyway.

By utilizing the hamburger and hidden menu, you have successfully prioritized your main goal, while lessening the distractions of other choices.

The power of popularity

Of course the one element that makes the hamburger icon usable at all is its sheer recognizability. The fact is, users have been interacting with it since roughly 2010, when it started spreading in mobile applications. A/B tests show steady improvement in engagement every year, which can most likely be attributed to increased exposure.

Although the hamburger is widely recognizable, it’s not yet reached complete saturation, which brings us to...

The Not-so-good Not Universally recognized by users

The hamburger is well-known, but it still has a few blind spots, making it a riskier choice than a straightforward navigation menu. Anecdotally, it is believed that users who browse on mobile the least are also the least familiar with the menu icon as we know it. Generally speaking, this is especially true in older demos, specifically people 65 years and over.

Another click, another barrier

Perhaps the biggest drawback to using the hamburger icon in lieu of a more standard menu is the extra action a user must take to get where they want to go. One of the guiding principles of good UX dictates that we eliminate as many barriers as possible between users and content. Remember when I brought up functional simplicity earlier? This is it.

Continue reading %Are Users Ready for the Desktop Hamburger Icon?%

Six Simple Mind Tricks to Help You Learn JavaScript Faster

Mo, 2015-09-28 20:00

When people try to learn JavaScript, or any coding skill really, they often run into the same challenges:

  • Some concepts can be confusing, especially if you’re coming from another language.
  • It’s hard to find the time (and sometimes the motivation) to learn.
  • Once you’ve understood something, it’s all too easy to forget it again.
  • The tooling landscape is so vast and constantly changing that it’s difficult to know where to begin.

Fortunately, these challenges can be recognized and ultimately conquered. In this article, I’m going to present six mind tricks which will help you learn JavaScript faster and become a happier, more productive coder.

1. Don’t Let Future Decisions Stop You from Progressing Now

For many people learning JavaScript, one of the first questions they ask is which framework to use (and let’s be fair, there’s a lot). But if you haven’t gotten comfortable with raw JavaScript, this is the wrong question to be asking. You’ll spend all of your time researching different frameworks and none of your time actually moving forwards.

One way to help get out of the indecision trap is to have a road map for what you need to learn. For example, to become a front-end developer, your road map might look like this:

Breaking it down further, you can make a functional web page with just HTML and CSS. Seeing the individual steps laid out like this, it becomes easier to see what to focus on now so you don’t waste time worrying about things that should come later.

For those who would find it helpful, I’ve written a more detailed learning road map for becoming a front-end developer.

2. Don’t Let Confidence Trick You into Forgetting Things

Understanding a concept quickly can be one of the most damaging things to your progress in learning JavaScript. Allow me to explain.

When you read something and it makes sense, it can be tempting to move on to the next thing immediately. Maybe you’ll understand the next thing and then move on again. But soon, you’ll arrive at a point where you realize you’ve forgotten some of the previous things you’ve learned, so you need to go back. You give the previous concepts a quick glance to refresh your memory and then move on again. But now you’ve forgotten something else. You keep repeating this back-and-forth dance until you get to a point where you realize you’re completely lost. You get discouraged, take a break, and then when you try to come back, you’ve forgotten everything.

Fortunately there’s a simple two-step cure for this problem:

  1. Limit the amount of stuff you learn at one time.
  2. Practice for real — actually write code.

When you learn a new concept, make sure to try it out, play with it, get comfortable with it, and even combine it with other concepts. It’s so important to actually type out the code in any examples you are following, because that’s what helps you absorb it. Also, limiting the amount you learn at one time will help you retain the material, for the simple reason that it’s easier to remember fewer things.

This process feels like it takes longer than just reading through things and moving quickly, but it actually takes much less time because you won’t need to backtrack as much. I learned this the hard way on several occasions.

Continue reading %Six Simple Mind Tricks to Help You Learn JavaScript Faster%

Easy Editorial Workflows with the WordPress EditFlow Plugin

Mo, 2015-09-28 19:00

As an editor, I have to collaborate with different writers. For example, sending them comments, feedback and changing the status of articles. Email is a very powerful tool most of us use multiple times per day for exchanging messages and collaboration. However, using email for editing and publishing tasks can be a quite painful, especially when you also have a team of writers.

There should be an alternative to the email way in handling such tasks. Since we are talking WordPress here, I will introduce you to a wonderful plugin that can solve these issues called EditFlow, and share with you how I use it to manage my team of writers.

What Is EditFlow Anyway?

EditFlow is a plugin which enables you to collaborate with your editorial team within the WordPress dashboard. You can for instance assign them tasks, add them to groups and exchange comments. EditFlow comes with many different features, which you can find more information about, here.

Continue reading %Easy Editorial Workflows with the WordPress EditFlow Plugin%

What Developers Need to Know about the Pebble Time Round

Mo, 2015-09-28 18:00

Back in March, Pebble released news of the Pebble Time and I put together a summary of what that meant for Pebble developers. Last week, they released their latest big news - the Pebble Time Round. Here's what Pebble developers and tinkerers need to know about the new device.

The Form Factor

The new Pebble Time Round is not only round but super thin and light too. It has the same CPU, maximum resource size, number of colors supported, sensors, microphone and smart accessory port as the Pebble Time. The only difference is that the screen resolution is now 180x180 pixels and is (of course) round.

The circular shape actually allows for a slightly larger watchface:

One downside of the reduced size is a reduction in battery life. The Pebble Time Round has a two day battery life and instead focuses on super fast charging - 15 minutes of charging brings a day of battery life.

Sadly, it is also not quite as water resistant either. It can withstand rain and showers but swimming with a Pebble Time Round won't end well.

The Round Platform Is Called "Chalk"

The previous two platforms were "Aplite" and "Basalt". "Aplite" is the original Pebble platform and "Basalt" is one for the Pebble Time. Developing for the round format requires a third platform type called "Chalk".

An Emulator is Available

CloudPebble's Beta already has an emulator ready and waiting for you to experiment with the "Chalk" platform. You can head over right now and try out any of your existing apps to see how they'll look.

You Need To Calculate Coordinates At Runtime

This is the most important tip I found whilst researching on the new changes. Avoid setting and using constant values like SCREEN_WIDTH and SCREEN_HEIGHT - these will be different for different versions of the device! You can inspect the size of your app's window root layer at runtime:

[code language="c"]
Layer *window_layer = window_get_root_layer(s_window);
GRect bounds = layer_get_bounds(window_layer);
[/code]

Avoid this:

[code language="c"]
Layer *layer = layer_create(GRect(0, 0, 144, 168));
[/code]

Instead, do this:

[code language="c"]
GRect bounds = layer_get_bounds(parent_layer);
Layer *layer = layer_create(bounds);
[/code]

One of the main things that prevents existing apps from working on the new device is hardcoded values like this, so if you are porting across an existing app - check for hardcoded screen sizes first and take those away.

Drawing Circles Is Easy

Turns out, when you've got a round watchface, you end up drawing a lot more circular shapes. The Pebble SDK now has some new functions to help with managing a circular interface.

Drawing a Circular Line

graphics_draw_arc() - Draws a line clockwise in an arc shape between two angles in a specific GRect area. This function is better suited to centering circles correctly in the app than the older graphics_draw_circle(). That function makes it hard to center your circle between half-pixels. The new function makes this much easier.

Here is an example of what this would look like in code:

[code language="c"]
graphics_draw_arc(ctx, inset_bounds, GOvalScaleModeFillCircle, start_angle, end_angle);
[/code]

Drawing a Filled Circle

graphics_fill_radial() - Fills a circle clockwise between two angles. You can adjust its inner inset radius to create donut shapes too. This is favorable to the older graphics_fill_circle() for similar reasons to the arc function above but also because of the ability to draw donut style shapes.

Here is an example of this in action from Pebble's Time Dots" example:

[code language="c"]
int minute_angle = get_angle_for_minute(s_minutes);
GRect frame = grect_inset(bounds, GEdgeInsets(10));
graphics_context_set_fill_color(ctx, MINUTES_COLOR);
graphics_fill_radial(ctx, frame, GOvalScaleModeFitCircle, 20, 0, DEG_TO_TRIGANGLE(minute_angle));
[/code]

You can see this in action in the app here:

Placing Elements Around a Circle

gpoint_from_polar() - Returns a GPoint within a specified angle inside a GRect. Basically, provides a single point on a circle rather than a full circle. Great for placing elements an equal distance around a center point. For example, this is how the series of dots representing 12 hours are included in the "Time Dots" example above:

[code language="c"]
for (int i = 0; i < 12; i++) {
int hour_angle = get_angle_for_hour(i);
GPoint pos = gpoint_from_polar(frame, GOvalScaleModeFitCircle, DEG_TO_TRIGANGLE(hour_angle));

graphics_context_set_fill_color(ctx, i <= s_hours ? HOURS_COLOR : HOURS_COLOR_INACTIVE);
graphics_fill_circle(ctx, pos, HOURS_RADIUS);
}
[/code]

Pretty handy!

Enhance Your UI For Each Platform

Just because there's a round design does not mean all of your Pebble app designs should be circular from this point on. It may actually be more beneficial to adapt and adjust your design for the different form factors. Porting your existing apps from the rectangular platforms might really benefit from a shuffle of elements. A great example is Katharine Berry's CalTrain app which adjusts its interface for the round screen in a really nice way:

[caption id="attachment_115746" align="aligncenter" width="1000"] Image courtesy of Pebble[/caption]

The app features a lot of curves which looks quite good in action as you can see from Katharine's wrist on her way to work:

[caption id="attachment_115747" align="aligncenter" width="768"] Image courtesy of Katharine from Pebble[/caption]

Continue reading %What Developers Need to Know about the Pebble Time Round%

9 Answers to Freelancers Frequently Asked Tax Questions

Mo, 2015-09-28 16:00

Ah taxes. They led to the arrest of Al Capone. They had a little something to do with the Revolutionary War. They keep the Swiss banks in business.

They’re also a thorn in the side of every freelancer.

Unlike full-time employees, we freelancers have to do our own taxes - a process that can easily become overwhelming. 1099s and 1040s haunt our dreams. Expenses and deductions taunt us with their complexity. While we may have gotten into the freelance game for the autonomy, I doubt most of us would protest if someone else stepped in to handle things.

But not everyone can afford to hire an accountant, so to help you navigate the choppy waters of DIY tax filing, here are nine tax questions frequently asked by freelancers.

Continue reading %9 Answers to Freelancers Frequently Asked Tax Questions%

Flexible and Easily Maintainable Laravel + Angular Material Apps

Mo, 2015-09-28 16:00

In this article, we’re going to set up a Laravel API with Angular Material for the front end. We’re also going to follow best practices that will help us scale with the number of developers working on the project and the complexity behind it. Most tutorials cover this topic from another perspective - they completely forget about scaling. While this tutorial is not targeted at small todo apps, it is extremely helpful if you’re planning to work with other developers on a big project.

Here’s a demo built with Laravel and Angular Material.

Setting up Laravel Creating a project

We’re going to start by pulling in the latest Laravel - 5.1 at the time of writing.

composer create-project laravel/laravel myapp --prefer-dist Configuring the environment

All the consequent commands will be ran inside the myapp directory. Throughout the remainder of this tutorial, we’ll assume you’re running a Linux environment if you’re following along. If you aren’t you’re encouraged to install Homestead Improved as a virtual Linux environment in which to follow along.

cd myapp

Next, we’re going to update our .env file with the database connection credentials:

DB_HOST=localhost DB_DATABASE=your-db-name DB_USERNAME=your-username DB_PASSWORD=your-password

Once your app has been configured, you should see the Laravel 5 greeting page.

Continue reading %Flexible and Easily Maintainable Laravel + Angular Material Apps%

Origami: How to Build Terrific Prototypes in Minutes

Mo, 2015-09-28 15:00

Hello everyone. If you are just joining the Origami party I suggest you first read the first part of this series “App Prototyping: Getting started with Facebook Origami”, which will introduce you to the Origami and Quartz Composer philosophy, GUI and teach you how to get up and running with you first Origami project.

What Are We Making?

In this article, I'd like to show you how to put together an attractive prototype equipped with animations and interactions in a few easy steps.

[caption id="attachment_115723" align="alignright" width="325"] Let's make this![/caption]

There is no better way to learn than by doing, so for this tutorial we will be prototyping a vacation photo sharing app.

For your convenience, if you don’t want to go through the trouble of designing a lookalike app just to follow this tutorial, you can find all the assets used in our example below by following this Link.

Before we start

Before we get going, there are a few key points that you'll find helpful in understanding the way Origami works.

Coordinates

[caption id="attachment_115732" align="alignright" width="200"] The origin of the plane (x=0;y=0) is in the center of the devices screen.[/caption]

The first item you should keep in mind is the coordinates system. In contrast to building with quartz composer patches, Origami patches such as Layer/Layer Group or Text Layers use pixel coordinates.

Progress Values

Values in the range of 0 to 1 are a common concept in Origami prototyping. When putting together an animation you will need to wire a 'switch patch' that triggers either a 0 or 1 and is connected to a transition in which you configure different animation properties.

Like a common light switch, switches can only be in one of two positions – values of either 0 or 1, or ON and OFF, or Start and Finish. Switches are commonly used as triggers for other patches.

[caption id="attachment_115729" align="alignright" width="234"] A switch patch is the most common use case of the binary values 0 and 1 portrayed as ON and OFF state.[/caption]

Keyboard Shortcuts

Luckily Origami comes equipped with a lot of keyboard shortcuts that speed up the prototyping process even more.

Shortcuts can be used when hovering the mouse over the work canvas.

You can find a full list of these shortcuts at the Origami's official documentation page by following this link.

Folder Structures

While the location of your assets doesn’t directly affect the development of your prototype, it is convenient to keep all of your assets in one folder with the Origami project. So, just in case you mess up the wiring of a patch, you can just remove the layer completely and easily re-add it in the project again.

[caption id="attachment_115730" align="aligncenter" width="550"] A demo project structure.[/caption]

Let's start prototyping

First we need to start a new Origami Project. If you don’t know how to do that, follow the instructions on the first article of this series as we mentioned earlier.

[author_more]
App Prototyping: Getting Started with Facebook Origami
Prototyping for Android with Material Design
The 100 Year Old Trick to Writing at 240 Words Per Minute
[/author_more]

When starting a new project, I like to import all of the image layers that I intend to use and arrange them how they will logically appear in the prototype.

This saves a lot of time when you are dealing with a smaller project with just a few components like the one we are using in the example.

You can add an image layer by dragging and dropping pictures straight into the canvas. Alternatively, you can manually add an image layer from the patch explorer window.

[caption id="attachment_115721" align="aligncenter" width="640"] Importing all media used in our prototype.[/caption]

Since we are building a 2-page prototype, it is good practice to use 'Layer Group Patches' so we don’t get lost in all the wiring that will go on for each page. Create a layer group patch by pressing 'G' on your keyboard (or by dragging and dropping the patch from the patch inspector).

After successfully adding the images in the Layer Group patch, you will notice that the Layer Group contents are not being rendered in the viewer. Don't panic!

The issue is we haven’t yet told Origami to render the output that comes from the layer group patch on the device screen. To do this, we must add a new layer patch and wire the Image output of the Layer Group patch into the input image property of the Layer patch as shown in the GIF below.

After dividing the components of the second page and adding them to the layer group, you will notice that the items on the second page overlap those of the first.

There are many ways to solve this depending on what you are trying to achieve. Since we want the second page to slide in horizontally, we can move it out of the way by changing the X-position property of the patch to -800. Easy.

To configure and change patch properties, just click the patch inspector icon in the canvas window.

[caption id="attachment_115727" align="aligncenter" width="640"] Opening the Patch Inspector[/caption]

Great! Now we want to go to that second page when tapping the “Explore Now” button on the app's welcome screen. We also want the second screen of the app to slide in elegantly – maybe even with a groovy little bounce while it does so.

To accomplish that we are going to drop 5 patches into our work canvas. Don't worry if this sounds a little complex or overwhelming – you will see that it is fairly easy to wire them together once you understand the logic.

What we will be using

In the Patch Explorer window you are going to search for the following five patches:

  1. Hit Area patch: This is the place on the screen where you want to catch events
  2. Interaction 2 patch: This patch catches interaction events from a layer patch (or the whole screen if not connected to any patch).
  3. Switch patch: Switch patch uses exactly like a light switch. It starts out as off and when you flip it will turn on.
  4. Transition patch: This patch takes a number in the range of 0 to 1 and converts it to a number within a range starting with Start Value and ending in End Value.
  5. Pop Animation patch: This patch animates a changing value with a spring.
Connecting the Dots

We've got our patches – it's time to wire them together.

First we set up our Hit Area patch on top of the “Explore Now” button to catch the Tap event through the Interaction patch.

After the Interaction patch catches the tap event on the hit area, it will trigger the ON state in our Switch patch, which will then send a value of 1 to the transition patch. This tells the transition patch to start increment from -800 to 0.

These incrementing numbers will be passed through a pop animation, the progress of which will be wired to the X-position of the Layer it's connected to.

For this effect to work like the example, you should first change the patch properties of the Layer Group (which contains the output of our second page) to -800 X-position and give it an Anchor Point of the value of Center.

[caption id="attachment_115724" align="aligncenter" width="985"] To achieve the exact same results, copy the same properties for the patches below.[/caption]

Since we have set the start value of the transition to -800, the Layer patch will zoom in from -800px horizontally off screen, before bouncing to a stop in the center of screen, thanks to our Pop Animation patch. To achieve the same effect to the example prototype, just change the Bounciness to 20 and Speed to 6 of the Pop Animation patch (but feel free to tweak it).

Continue reading %Origami: How to Build Terrific Prototypes in Minutes%

How to Solve Coding Anti-Patterns for Ruby Rookies

Mo, 2015-09-28 14:00

As a freelance developer, I often work with developers from different programming backgrounds and of different skill-levels. Over time, I've learned to tell a programmer's Ruby level of experience by looking at the code they've written. Not only that, I can also place a safe bet on the programmer's coding background based on certain patterns within the code that give subtle clues as to the coder's previous programming experiences. There are certain coding practices that Ruby Rookies tend to employ often. Let's call these anti-patterns. This post enumerates the most common of these anti-patterns.

Continue reading %How to Solve Coding Anti-Patterns for Ruby Rookies%

16 Best Product Hunt Finds for Entrepreneurs

Sa, 2015-09-26 16:00

Some people relax by surfing Facebook or watching Netflix. I relax by going on Product Hunt. If you’re a little hazy on what Product Hunt is, picture a newsfeed devoted to the coolest new products—from apps and sites to books and resources.

Besides being entertaining, inspiring, and addictive, Product Hunt is also a veritable gold mine of cool tools. Check out my 16 favorites for entrepreneurs.

Continue reading %16 Best Product Hunt Finds for Entrepreneurs%

Mastering Your Inbox with the Gmail JavaScript API

Fr, 2015-09-25 18:00

In this article, we’re going to build a basic Gmail inbox and message viewing app using the Gmail RESTful API. The purpose of this article is to give you a good starting point to create cool new JavaScript apps of your own using this API. We’re going to use jQuery and Bootstrap to take some weight out of the code base so we can focus on getting something working quickly without worrying about cross-browser JavaScript inconsistencies and basic styling.

As ever the complete code for this article can be found on our GitHub repo.

Enabling the Gmail API on Your Google Account

First off, we need to enable Gmail API access to get our API credentials. To do this, we need to visit Google’s Developer Console in our favourite web browser. From there, we need to create a project (or choose an existing one) and go to the APIs section. Choose “Gmail API” under the Google Apps APIs section and click the “Enable API” button.

Now we need to create two sets of credentials, one for an OAuth 2.0 client ID for a web application and the other to create a browser API key. This can be done in the credentials section of the Google Developer Console by clicking the “Add Credentials” button.

For the browser API key we need to only fill in the “name” field. However, for production I’d recommend adding a HTTP referrer (this will prevent abuse of our API key from non-authorized domains). For the OAuth 2.0 client ID we must enter at least one authorized JavaScript origin. For a local development environment this will likely be http://localhost or similar. We do not need to enter an authorized redirect URI.

Once we’ve filled in the necessary fields we should be able to see our credentials back in the Credentials section. Keep this info open in a browser tab for later.

Connecting to the Gmail API

[author_more]

Even though the Gmail API is a standard REST API using OAuth 2.0 we recommend using Google’s own JavaScript libraries for connecting to and working with any Google-authored APIs. This is because Google has already packaged up authentication logic and the required dependencies into a single include file — less work for us!

So, first things first – let’s set up our HTML file which we’re going to use as the base of our app. For the purpose of this app we’re going to include all of our code in a single HTML file. In a production environment Id recommend splitting out HTML, CSS and JavaScript into separate files.

<!doctype html> <html> <head> <title>Gmail API demo</title> <meta charset="UTF-8"> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"> <style> .hidden{ display: none; } </style> </head> <body> <div class="container"> <h1>Gmail API demo</h1> <button id="authorize-button" class="btn btn-primary hidden">Authorize</button> <table class="table table-striped table-inbox hidden"> <thead> <tr> <th>From</th> <th>Subject</th> <th>Date/Time</th> </tr> </thead> <tbody></tbody> </table> </div> <script src="//code.jquery.com/jquery-1.11.3.min.js"></script> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <script type="text/javascript"> var clientId = 'xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com'; var apiKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; var scopes = 'https://www.googleapis.com/auth/gmail.readonly'; </script> <script src="https://apis.google.com/js/client.js?onload=handleClientLoad"></script> </body> </html>

Right at the bottom (above the closing </body> tag) is where we include Google’s JavaScript client library. Notice the query string on the end, this contains the callback function which will be executed once the script has loaded — we’ll use that to initialize our app a little later. Just above that is where we are defining our API credentials, we need to paste these from the Google Developer Console Credentials section. We also define which permissions we’ll require from the user, these are known as scopes. For the purpose of this app we only require read-only Gmail access. It’s good practice to request as few permissions as possible from the user — this provides the user peace of mind that we’re not going to do something nefarious like send emails on their behalf without them knowing.

Other than that we’ve got a button which will allow the user to authorize us to access their Gmail account, and we’ve also stubbed out a table to hold our inbox data once we fetch it. And, as mentioned earlier, we’ve included the necessary files for jQuery and Bootstrap.

Authenticating the User

Now we’re going to provide a mechanism for the user to authenticate us to access their Gmail account. As mentioned above, we need to build out a function named handleClientLoad() which will automatically be called once Google’s JavaScript client library has loaded into the page. This function will then call a chain of other functions which will eventually lead us to fetching their inbox.

function handleClientLoad() { gapi.client.setApiKey(apiKey); window.setTimeout(checkAuth, 1); } function checkAuth() { gapi.auth.authorize({ client_id: clientId, scope: scopes, immediate: true }, handleAuthResult); } function handleAuthClick() { gapi.auth.authorize({ client_id: clientId, scope: scopes, immediate: false }, handleAuthResult); return false; } function handleAuthResult(authResult) { if(authResult && !authResult.error) { loadGmailApi(); $('#authorize-button').remove(); $('.table-inbox').removeClass("hidden"); } else { $('#authorize-button').removeClass("hidden"); $('#authorize-button').on('click', function(){ handleAuthClick(); }); } } function loadGmailApi() { gapi.client.load('gmail', 'v1', displayInbox); }

We should insert this code directly below where we set the API credentials, within the same SCRIPT block.

To summarise the process this chain of function calls goes through:

  1. handleClientLoad() simply sets the API key and passes off to checkAuth() after 1 millisecond.
  2. checkAuth() checks if the user has previously authenticated our app with Google. Setting the immediate parameter to true here means that we do not prompt the user with a login/permissions modal if they are not authenticated. We then pass the authentication result to handleAuthResult().
  3. handleAuthResult() then does one of two things; if the user is already authenticated it’ll load the Gmail API using loadGmailApi(), alternatively it’ll display the authorize button on the UI and attach a click event to it which will trigger handleAuthClick()
  4. handleAuthClick() simply executes the same authentication function as checkAuth() but will present the user with a login/permissions modal. Once the user authenticates the same handleAuthResult() function from before is triggered.
  5. Once those series of functions have been executed and the user has authenticated we should always find ourselves at the loadGmailApi() function. This simply loads the Gmail API functionality from Google’s JavaScript client library and then calls our displayInbox() function.

Continue reading %Mastering Your Inbox with the Gmail JavaScript API%