Javascript News

Syndicate content
Pipes Output
Updated: 48 weeks 6 days ago

Watch: Creating High Resolution Background Images with CSS

Mo, 2015-09-14 17:30

In this screencast Russ Weakley shows you how to create high resolution background images including at a 2x and 3x resolution for narrow and wide screens using the webkit-min-device-pixel-ratio and min-resolution media queries.

View the code sample provided.

Loading the player...

Continue reading %Watch: Creating High Resolution Background Images with CSS%

How to Pitch Freelance Services to Small Businesses

Mo, 2015-09-14 16:00

Most freelancers share a common dream. No, not the one where the IRS nixes all of your coffee shop tax deductions. It’s the dream of never having to pitch to clients. No more cold calls or unsolicited emails. No more selling your services to strangers. It’s a dream of self-replicating referrals. But the road to […]

Continue reading %How to Pitch Freelance Services to Small Businesses%

Drupal 8 Third Party Settings and Pseudo-Fields

Mo, 2015-09-14 16:00

In the first installment of this series we started our journey towards creating some simple but powerful functionality. The goal we set was to have the possibility to load a form on each node page and to be able to choose which form type should be used on the different node bundles.

The first step is done. We created a custom plugin type called ReusableForm already featured with a base plugin class that new plugins can extend. Additionally, we saw that each plugin will interact with a form class that is defined in their annotation. And like with the plugins, we also created a base class new forms can extend.

It follows to see how we can configure the core node types to use one of the plugins defined on the site and how to render the relevant form when viewing the node. But first, in order to have something to work with, let’s create our first ReusableForm plugin that uses a very simple form.

Our first plugin

Inside the src/Form folder of our module, create a class called BasicForm.php (or whatever you want to call it). Inside, we can have this simple form definition:

Continue reading %Drupal 8 Third Party Settings and Pseudo-Fields%

Create Elegant (but Easy) Interactions Using Sketch & Atomic.io

Mo, 2015-09-14 15:00

I’ve spoken in favour of Sketch App for months now, and aside from having discovered many different reasons to use it for all types of design work, I still in fact find more reasons everyday.

One of the more recent incentives is the beta release of Atomic.io, which I find surprisingly similar to Sketch in terms of interface and executability.

I wrote about Atomic.io only recently, where we created a basic icon directly in Atomic and demonstrated how the icon would animate if we interacted with it, but this time we’re going to design something in Sketch and copy it over to Atomic.

Here’s an example animation of what we’ll be making.

Creating a Simple Loading Screen Animation in Sketch

When you open an app for the first time you might be shown a tiny animation that lets the user know that their app is loading. Lets assume that SitePoint has hired us to create said animation and we’ll design the screen in Sketch App first. Press “A” to start with and select the iPhone 6 artboard from The Inspector.

It needs a blue background (#4494c2 will do), but we’ll want to animate it in Atomic later on so an artboard background would not be suitable in this case. Instead, create a Rectangle (“R”) as big as the artboard and add a blue fill, emulating a background.

Make sure to remove the default border, and repeat this step once more with a white background (leave it underneath the blue).

Press “T” to create some text (any colour, any size, it doesn’t matter) and once again move it behind all the other layers. We’ll call it “App”, and all this will do is demonstrate how our hypothetical app will animate in after the loading screen.

[caption id="attachment_114754" align="aligncenter" width="965"] Setting Up the Artboard in Sketch[/caption]

Recreating the SitePoint Logo

Press “R” again, remove the default border, and create a white rectangle that is 50x16px with a Rotate of -45deg. When that’s done, Duplicate it (command+d) and use the horizontal flip button (next to Rotate). It should look something like this.

[caption id="attachment_114755" align="aligncenter" width="965"] Constructing Our First Shape[/caption]

Hold Shift while you select both of these rectangles at the same time, and lets starting using some tools from the menu bar up top. You’ll need to use these tools in this order:

  1. Union
  2. Flatten
  3. Edit

After using the Edit tool, it’ll be obvious that our rectangles have now become a singular flattened vector shape, and that we can edit its points. While holding Shift again, select three of them (in the image below these are highlighted in black) and use the inspector to change the Corners to 5. Almost there.

Duplicate, flip, and move both layers until we have this:

[caption id="attachment_114757" align="aligncenter" width="965"] Finalising Our Design in Sketch[/caption]

Copying Layers from Sketch to Atomic

We’re done with our .sketch file now. Open your web browser and skip over to Atomic.io. Login (or register if you’ve never used it before), create a “New Project” and then “New Design”; the first thing we need to do is select the “Pages” tab (on the left) and then look to the opposite side of the screen and choose the iPhone 6 Portrait Preset.

[caption id="attachment_114758" align="aligncenter" width="1366"] Creating the Artboard in Atomic[/caption]

What we have now is a blank canvas, and this step mainly involves copying layers from Sketch App into Atomic. Copying-in the entire artboard won’t work because Atomic will force this into a singular flattened layer. But that doesn’t matter - we need to split our design into several Pages anyway, to represent the different stages in the animation. Copy the layers in first.

[caption id="attachment_114759" align="aligncenter" width="1366"] Copying Layers Over to Atomic[/caption]

Setting the Stage in Atomic

Lets move all the layers to where they should be - “setting the stage” so to speak. Our “App” text layer will slide in from the right, so it’s not needed on stage at the moment. Make the “X” axis of this layer “373px” so that it appears off-stage.

Do the same for our white background.

Make sure “App” is entered vertically.

You’ll need to switch to the Layers Panel before you can select an individual layer. Flick back to Pages, click the hamburger menu, and Duplicate. Do it again so there’s three versions of this same screen. Now lets start with the first screen.

One “Page” Equals One Stage of the Animation

Our animation will begin with the logo not visible. Since our logo consists of two layers, make the left side appear off-screen to the left, and the right side appear off-screen to the right. In the next step we will animate these layers to fly in from either side of the canvas with a smooth bouncy effect.

Page one looks a little blank at the moment; this is desired.

[caption id="attachment_114760" align="aligncenter" width="1366"] Setting the Stage in Atomic[/caption]

Page two is fine as it is.

Skip to number three and select all of the layers at once by holding Shift as you do so, then drag the layers so that the white background fills the canvas completely, and our blue background (+logo) is now off-stage. Since all layers were converted to images when we copied them from Sketch, our “App” text layer has now lost its auto-width. You’ll need to move that layer manually so that it snaps to the dead-center grid.

Continue reading %Create Elegant (but Easy) Interactions Using Sketch & Atomic.io%

Ruby on Medicine: Counting Word Frequency in a File

Mo, 2015-09-14 14:00

Welcome to a new article in SitePoint's Ruby on Medicine series, where I show how the Ruby programming language can be applied to tasks related to the medical domain.

Newbie, moderate, and advanced Ruby programmers can benefit from this series, in addition to health/medical researchers and practitioners looking forward to learning the Ruby programming language, and apply it to their domain.

In this article, I'm going to show you how we can use Ruby to check the frequency of occurrence of words in some file. Counting the frequency of occurrence of words can come in handy in large text files, such as the OMIM^®^ – Online Mendelian Inheritance in Man^®^ file, which we worked with in the last article.. The reason counting the frequency of words could be beneficial is that going through the list of words and their frequencies will give us a more sense of what the document is about. It can also pinpoint any mistakes and misspellings, especially when we have a dictionary to compare against. When a word from the dictionary is not listed in your output, for instance, you can simply conclude that a misspelling has occurred to that word, or abbreviations were used rather than the words themselves.

Continue reading %Ruby on Medicine: Counting Word Frequency in a File%

Meet Igaro App — Potentially the Web’s Finest SPA Framework

Fr, 2015-09-11 18:00

Some say that a web page should start with HTML, which is (or was) thought of as content, and that functionality should load on top of that (the filtering etc). Right or wrong? With so much content now generated dynamically, perhaps it’s time to revisit the way we do website design. Whichever way you lean, the back-end will largely be doing the same as it was ten years ago, but with a bit of partial serving and new protocol support. We’re still left with the problems of old: building and rendering a page made up of multiple fragments and trying not to hit a database server multiple times, which means careful thought on how data passes through the modules that represent them. And front-end wise, there’s the pain of trying to put a state into the /x/y/x URL being served, even though the user never loaded x and x/y to begin with.

I always thought there had to be a better way, but JavaScript, or the variety of devices that ran it, were never really up to shifting the work load from back-end to front-end. Bits yes, but not all of it.

And then they were.

Along came the frameworks; Backbone, still here, but diminished, Polymer, the next big thing — last year, the Angular explosion — now smoldering, and more recently Facebook’s React. I feel something is different with React, something that tells me the web is finally heading in the right direction. For one it isn’t using templates and thus has no need for two way data-binding.

The real architectural decision is not what templating language to use, or whether one should use TypeScript, or use a framework at all, it’s whether anything at all should be rendered server-side. A year ago it was mandatory, because the service that could make or break a product, GoogleBot, couldn’t handle a web app. But now it can, and so I must ask you the question you’ve asked yourself many times over the past several years: “Should I reload that part of the page via Ajax as a fragment, or regenerate that piece with front-end code (a.k.a. React), or modify the DOM structure with front-end code, or just reload the page?”

Then I will ask you one more question. It’s 2015. Why are we still asking this question?

A year earlier I embarked on the road to create a solution.

Introducing the Igaro App JavaScript Framework

Igaro App is a web app framework — a.k.a. an SPA (Single Page Application) framework — but one which takes a radical departure from the norms. For a start it uses no HTML and no MVC. It avoids using DOM query selector methods to try to improve performance, and therefore has no template engine. Instead it uses routes to build pages, and standard CSS for styling and layout.

It is written in pure JavaScript ES3/5/6 (no dependencies) and aims to outclass and outperform not at several things, but at everything. It’s purpose is to prove that by thinking outside the box it is possible to produce an architecturally brilliant foundation on which developers can code using the JavaScript they love, and not some abstracted, string parsed derivative.

Bold ideas and bold claims, and you should be skeptical. When you first view the website for Igaro App you may wonder where the center aligned “Apple like” sales page is, with its big fancy fonts and basic images. It’s inherently different because the website is the web app, which is also the downloadable repository. It’s functional and functioning, with all the documentation and widgets built right in.

Go ahead and clone it right now:

mkdir igaro git clone https://github.com/igaro/app.git igaro/git npm install grunt-cli gem install compass cd igaro/git npm install grunt

Once cloned and running, the user has a development environment ready to go. Igaro compiles into two modes — debug and deploy and a web server for each can be found on ports 3006 and 3007 respectively. These will reload automatically as you work. Modifying “pages”, or routes, is as simple as editing the included route.* files . To see which route file maps to which page, or to inspect the source code for any page, just click the curly braces in the header section. A XHR widget allows for seamless JSON retrieval and creating new widgets to span over multiple pages can be done by inspecting any of the included instance.* files.

Continue reading %Meet Igaro App — Potentially the Web’s Finest SPA Framework%

Watch: The Swift App Infrustructure

Fr, 2015-09-11 17:30

In this screencast, we learn about what the MVC framework is and how it is used in iOS apps. MVC is the foundation of how our app is organized. Understanding how to implement it will allow us to construct an app that follows Apple's guidelines and a proven framework. In this screencast I'll go through what you need to know about the app infrastructure.

This is one lesson from my new course Introduction To Swift, view it on SitePoint Premium. The best thing is that you'll create a real activity logger app, which you can then take and use or use what you learnt to create your own applications.

Loading the player...

Continue reading %Watch: The Swift App Infrustructure%

4 Simple Things to Remember about Apostrophes

Fr, 2015-09-11 17:00

Apostrophes can seem like trivial, petty little things, and hardly worth the trouble they cause! But they are quite important. Using them well can make your writing a lot clearer, and using them poorly is a really bad look.

So take a few moments to make sure you’ve got a handle on apostrophes. At the end, I have a simple test for you.

1. Ownership

A major use of apostrophes is to indicate possession, or ownership. For example, the bone of the dog is the dog’s bone. If we leave out the apostrophe in dog’s bone, we have dogs, indicating the plural—that is, many dogs—which will cause momentary confusion for the reader.

Exceptions

There are some important exceptions to watch out for. Tradition dictates that these possessives don’t have an apostrophe: hers, its, yours, ours, theirs, his.

These are known as possessive pronouns. You just have to remember that they don’t have an apostrophe! (See below for more on its vs it’s.)

Dealing with words ending in s

What if it’s the dog of James? James already ends in s. The answer depends on how you prefer to say it aloud. Either of these is fine: James’ dog or James’s dog.

Ownership and plurals

The dog’s bone means the bone of the dog—that is, just of one dog. What about the bone of the dogs? Dogs already has an s at the end. The answer is simple: just place the apostrophe after the s: the dogs’ bone.

Watch out for some plurals. The plural of company is companies. So we get the company’s website (that is, the website of the company), but the companies’ websites (or the websites of the companies).

Family names can be tricky. The Jones family can be referred to as the Joneses. In that case, you’d refer to the Joneses’ dog, with the apostrophe at the end.

Also be careful with words like men, women and children. Because these are already plural, you just add ’s as usual. For example, the men’s team played the women’s team.

Continue reading %4 Simple Things to Remember about Apostrophes%

Drupal 8 Custom Plugin Types

Fr, 2015-09-11 16:00

Drupal 8 comes with a great addition to the backend developer toolkit in the form of the plugin system. Completely new, specific to Drupal and evolved from serving only a few specific purposes, plugins have become the go-to system for reusable functionality in Drupal 8.

In this article series of two parts, we will use this system to build a feature that allows the use of custom forms together with node entities. After we’re done, we’ll be able to do the following:

  • configure node bundles to use one of multiple form types to be displayed together with the node display
  • easily define new form types by extending from a sensible base class

Because the topic is very well covered elsewhere, I will not go into the details of how plugins work. But do feel free to brush up on the theory before diving into the crux of it here. And if you want to take a look at the end result, the code we write in both articles can be found in this repository.

We will get started by creating our custom plugin type. To this end, we will have 2 interfaces and 6 classes. It sounds like much, but I assure you they are rather boilerplate and quick to set up. Then, in the next installment of this series, we will see how to use it for our reusable forms attached to nodes.

Continue reading %Drupal 8 Custom Plugin Types%

Saving Data Between Scenes in Unity

Fr, 2015-09-11 16:00

This tutorial assumes basic knowledge of Unity Engine. If you don’t have your own project set up, you can freely grab the project example linked here. You will also find a download of the completed project at the end of this article.

If you’re struggling with saving data between two scenes, this is the tutorial for you.

Starting Point

Download the example project:

[GitHub Repository link]
[ZIP Download]

The logic

Unity is a game engine with its own philosophy. Even though there are quite a few alternatives, it’s quite unique in the way it handles the building blocks of any game - game objects, scenes, code, scene graph. And by unique, I mean how easy it is to understand it.

If you’ve tried giving Unity a test run because it’s free to download, you were probably introduced to how its scripting is implemented. „Scripts“, written in either C#, JavaScript (or, since Unity 5, UnityScript) or Boo language, are components that are attached to any game object. From within a script, you’re free to access and manipulate the object the script is attached to, or any linked objects. It’s quite intuitive, easy to use, and fun to build with.

Supposedly, then you tried building a second level; say your first level was the interior of the house, and then your second level is outside of the house. The transition is using the door to load the next scene.

Here’s the core problem we’ll be tackling today. Each level within the Unity engine is called a „Scene“. You can edit the Scene using the graphical editor however you like. You can transition the scene using a single line of code (that is triggered, perhaps, by the player touching the door, or using an object, etc). Each scene has objects, which have „components“.

Generic „Objects“ represent what ever else makes up your level (meshes, triggers, particles, etc)

Each scene is built in its initial state. Transitioning the scene to another one means the new scene will be loaded at its initial state (naturally). But what about the player’s statistics, for example his ammo count, or experience, or inventory?

How do we preserve the data, when we can only write code in „Scripts“ - components of Game Objects - which just get destroyed during scene transitions?

Continue reading %Saving Data Between Scenes in Unity%

5 Responsive Design Pitfalls and How to Avoid Them

Fr, 2015-09-11 15:00

Picture this. You’ve just created a responsive masterpiece, and then you check it out on a mobile device. Things break in ways you never would have expected. Text is going haywire, animations are choppy, and your forms don’t look anything like how you styled them. You spend hours scouring the internet for answers to be led in circles. In frustration, you throw your computer out the window and accidentally hit the neighbor’s cat.

The good news is that I’m here to protect you from the types of mobile development pitfalls that will lead to you throwing your computer out a window. Here are the major pitfalls we’re going to cover:

Continue reading %5 Responsive Design Pitfalls and How to Avoid Them%

Preloading Images in Parallel with Promises

Do, 2015-09-10 20:00

The topic of this article is actually quite specific. Recently, I faced a situation where I needed to preload a lot of images in parallel. With the given constraints, it ended up being more challenging than first expected, and I certainly learnt a lot along the journey. But first, let me describe the situation shortly before getting started.

Let’s say we have a few “decks” on the page. Broadly speaking, a deck is a collection of images. We want to preload the images of each deck, and be able to know when a deck is done loading all its images. At this point, we are free to run any piece of code we want, such as adding a class to the deck, running an image sequence, logging something, whatever…

At first, it sounds quite easy. It even sounds very easy. Although perhaps you, like I did, overlooked a detail: we want all decks to load in parallel, not in sequence. In other words, we do not want to load all images from deck 1, then all images from deck 2, then all images from deck 3, and so on.

Indeed, it is not ideal because we end up having decks waiting for previous ones to finish. So in a scenario where the first deck has dozens of images, and the second one has only one or two, we would have to wait for the first deck to be fully loaded before being ready for deck 2. Ugh, not great. Surely we can do better!

So the idea is to load all the decks in parallel so that when a deck is fully loaded, we don’t have to wait for the others. To do so, the rough gist is to load the first image of all the decks, then the second of all the decks, and so on until all the images have been preloaded.

Alright, let's start with creating some markup so we all agree on what's going on.
By the way, in this article I will assume that you are familiar with the idea of promises. If it is not the case, I recommend this little reading.

Continue reading %Preloading Images in Parallel with Promises%

Responsive Schedules for WordPress with the Timetable Plugin

Do, 2015-09-10 19:15

Tables (and generally everything where cells are involved) can be a pain in WordPress. Offering a good viewing experience in these cases is often difficult, as one would need to take care of various resolutions and devices to work properly on a responsive website. I covered TablePress in April here on SitePoint, which also comes with a responsive plugin, making a great duo together. However, often tables like those created by TablePress don’t suffice, and a more professional alternative is needed. I’ve seen many conference websites struggle with this and some just end up putting the agenda on an Excel spreadsheet, which is a pity.

When organizing OSCAL 2015 (also proudly sponsored by SitePoint) our team had the exact same problem. After a long search, we were lucky to stumble upon the Timetable Responsive Schedule Plugin for WordPress on CodeCanyon, which looked very promising and also didn’t fail to reach our expectations at the end of the day.

I personally think of Timetable as a flagship plugin for stylish and responsive schedule creation in WordPress. The plugin also displayed the tables perfectly on mobile devices, which was a big relief for us when organizing the conference. Having said that, Timetable is designed “for most websites and types of business like gyms, kindergartens, health care or law related”, however the vast flexibility it offers allows you to adapt it to many other use cases (like a tech conference, in my case).

We're going to have a quick tour of the plugin’s functionalities so you can see if the plugin is able to cater your needs.

Continue reading %Responsive Schedules for WordPress with the Timetable Plugin%

Watch: Using className to Add Style

Do, 2015-09-10 17:30

Today is the epic conclusion of our Building a Stopwatch mini-series. We'll use className to add nice clean styles to our component. As a bonus, we'll remove duplication by creating a new Button component and using a special JSX feature called Spread Attributes. Enough jabber, let's get styling!

This is the fourth and final video in the Building a Stopwatch in React series.

Loading the player...

Continue reading %Watch: Using className to Add Style%

Creating an Accessible Breakout Game Using Web Audio and SVG

Do, 2015-09-10 15:30

As the co-author of Babylon.js, a WebGL gaming engine, I was always felt a little uneasy listening to folks discuss accessibility best practices at web conferences. The content created with Babylon.js is indeed completely inaccessible to blind people. Making the web accessible to everyone is very important. I’m more convinced than ever about that as I’m personally touched via my own son. And so I wanted to contribute to the accessibility of the web in some way.

That’s why I decided to work on creating a game that uses WebGL and is fully accessible, to prove that visual games aren’t inherently inaccessible. I chose to keep it simple, so I created a breakout clone, which you can see in action in the following YouTube video:

[embed width="560" height="315" src="https://youtu.be/25quyIGtujk"]

You can test it in a Web Audio compatible browser (see caniuse.com for a list) or download or peruse the source code on Github.

Now, let me share with you the background story of this game and all the experiments involved…

Once Upon a Time

It all started during the Kiwi Party 2014 conference, while listening to Laura Kalbag’s talk about guidelines for top accessible design considerations. I was discussing with Stéphane Deschamps, a lovely, funny and talented guy about my lack of knowledge on how to make WebGL accessible and how I could avoid people creating lots of inaccessible content. To motivate me, he challenged me. Probably without estimating the consequences: "it would be very cool if you’d manage to create an accessible breakout game!". Boom. The seed of what you see here got put in my brain right there and then. I started thinking about that in earnest and researched on how I could create such an experience.

First, I discovered that there were already accessible audio games available at audiogames.net and game-accessibility.com. I also researched best practices for creating games for blind people. While interesting to read, I wasn’t finding what I was looking for. I didn’t want to create a dedicated experience for blind people, I wanted to create a universal game, playable by anybody, regardless of ability. I’m convinced that the web was created for this reason and my dream was to embrace this philosophy in my game. I wanted to create a unique experience that could be played by all kind of users so they could share in the joy together. I wanted great visuals & sounds, not a "look it’s accessible, that’s why it can’t be as good" solution.

Continue reading %Creating an Accessible Breakout Game Using Web Audio and SVG%

Happy Ending: An Epic Saga of Guard and Docker

Do, 2015-09-10 14:00

I've never liked how projects pollute my system. Libraries, databases, message queues, you name it and I've had to install it. Within this shared universe, it's only a matter of time before worlds collide. Two projects each require a different Redis and I'm stuck being the human dependency resolver.

There have been past attempts at project silos. None of them have been as powerful or as promising as Docker. Even so, it's not without its rough edges. This is a story about one of those edges.

I have a Rails project with existing tests that I wish to Dockerize. What I don't have is a good way to get feedback as I refactor. I want to run Guard so I can do some TDD. Normally running Guard isn't a big deal, but Docker (at least, on the Mac) makes this an issue (it has to do with libnotify). It's difficult to impossible to get file changes to kick off your guards. New technologies come with trade-offs and sometimes the simple becomes difficult.

Continue reading %Happy Ending: An Epic Saga of Guard and Docker%

Watch: Structuring an Android Project

Do, 2015-09-10 06:47

When a project is created in Android Studio it contains several auto-generated files containing skeleton code for our project. In this video we look at what function these files perform and when and why we would edit them.

Loading the player...

Continue reading %Watch: Structuring an Android Project%

Getting Random with David Bowie and Fractals

Do, 2015-09-10 02:15

A small Jean Genie snuck off to the city,
Strung out on lasers and slash-back blazers,
Ate all your razors while pulling the waiters

Last week I saw the 'Bowie Is' Exhibition at ACMI, and the lyric above from his 'Jean Genie' (1973). I have no idea what a 'slash-back blazer' is, but, like lots of Bowie's best lyrics, it's a fantastic sounding phrase.

[caption id="attachment_114613" align="alignright" width="300"] The Verbasizer[/caption]

And for all the chunky guitar riffs, martian make-up and gender-bending outfits, my favorite part was probably some footage of Bowie explaining his fantastically nerdy song-writing process.

It works like this: Typically he would take a pile of newspapers, cut the sentences into strips and then reassemble the pieces into brand new random sentences. Later in the 1990's, Bowie worked with a programmer to create a system (the 'Verbasizer') that automated this newspaper cutting/joining process.

So what you end up with is a real kaleidoscope of meanings and topics and nouns and verbs all sort of slamming into each other. - David Bowie

While most of these generated phrases mean nothing, others becomes the seed for bigger ideas and stories.

And I find that even maybe four words in here would… ‘The top kills himself.’ That sounds like a boss, doesn’t it? And suddenly I get a vision of a boss in the 30s throwing himself out of a window in the Great Depression. That might be enough to set me off writing a song about that. - David Bowie

While this partly 'gives away the magician's trick', it also shows that often the true value of the random isn't really its 'randomness' – it's the 'accidental sense' that WE make of it.

Whether it's seeing faces in clouds or our future in tea-leaves, humans seem to be hard-wired to search for meaning–even in completely meaningless things. We can't help it.

Using Randomness in Design

I think that fractals are like a visual equivalent of Bowie's random sentence masher. Though they emerge from a meaningless world of numbers, we can't help making our own connections with them. And, like Bowie, software can help us with these too.

Frax

Tom Beddard's Sub.Blue has been a home to great fractal experiments since the mid-2000s. In 2011 he teamed up with Kai Krause (of Kai's Power Tools fame) and Be Weiss to create a new kind of graphics app.

A year ago they released an iPad app called Frax that can generate incredible imagery with very little effort. The Frax interface is very minimal – it's mostly swipes and pinches – so this is as close as you'll ever get to 'fractal fingerpainting'.

If you've got an IOS device, this is a fun introduction to fractals.

Chaotica

Chaotica is a fractal generation application available for most OSs. I'm not going to lie – you'll probably need to read some tutorials to get real value out of this application. While the interface isn't busy, it probably uses some concepts you may not be familiar with right now.

[caption id="attachment_114622" align="alignright" width="380"] The Chaotica UI[/caption]

However I think it is worth a small time investment as it's more versatile than Frax and has a strong, super-enthusiastic community behind it.

Chaotica Studio is $99 and Chaotica HD is $33, but the free version is very capable. The only limitations to the free edition are:

  • a 1280 x 960px maximum resolution
  • animations capped at 30-seconds

Certainly there's nothing preventing you from creating great, original work like the piece below.

Continue reading %Getting Random with David Bowie and Fractals%

Manipulating Images with the Python Imaging Library

Mi, 2015-09-09 22:00

In my previous article on time-saving tips for Pythonists, I mentioned that Python is a language that can inspire love in its users.

One reason for this is the number of time-saving libraries available for this language. A nice example is the Python Imaging Library (PIL), which is the focus of this article.

What You Can Do with PIL

PIL is a free library that adds image processing capabilities to your Python interpreter, supporting a range of image file formats such as PPM, PNG, JPEG, GIF, TIFF and BMP.

PIL offers several standard procedures for image processing/manipulation, such as:

  • pixel-based manipulations
  • masking and transparency handling
  • filtering (for example, blurring, contouring, smoothing, edge detection)
  • image enhancement (for example, sharpening, brightness adjustment, contrast)
  • geometrical, color and other transforms
  • adding text to images
  • cutting, pasting and merging images
  • creating thumbnails.
PIL and Pillow

One issue with PIL is that its most recent version, 1.1.7, was released in 2009, and only supports Python 1.5.2–2.7. Although the PIL site promises a forthcoming version for Python 3.X, its last commit was in 2011, and it appears that development has been discontinued.

Fortunately, all is not lost for Python 3.X users. A project called Pillow has forked the PIL repository and added Python 3.X support. Given that most readers will probably be working with Python 3.X, I'll focus on the Pillow update in this article.

Installing Pillow

Since Pillow supports versions of Python back to Python 2.4, I'll only focus on installing Pillow and not the older version of PIL.

Python on a Mac

I'm currently writing this tutorial on a Mac OS X Yosemite 10.10.5, and thus will describe how to install Pillow on a Mac OS X machine. But, don't worry, I'll provide a link at the end of this section that describes how to install Pillow on other operating systems.

I just want to note here that Mac OS X comes with Python pre-installed. However, the version most likely will be prior to 3.X.

For instance, on my machine, when I run $ python --version in the terminal, I get Python 2.7.10.

Python and pip

A very easy way to install Pillow is through pip.

If you don't have pip installed on your machine, simply type the following command in your terminal, and you're all done:

$ sudo easy_install pip

Now, to install Pillow, simply type the following in your terminal:

$ sudo pip install pillow

That was easy, wasn't it?

As I promised, for installing Pillow on other operating systems, you can find the instructions for that here.

Continue reading %Manipulating Images with the Python Imaging Library%

Promises in JavaScript Unit Tests: the Definitive Guide

Mi, 2015-09-09 20:00

Promises are becoming a common part of JavaScript code. The native Promise object is already supported by all the major browsers including Chrome, Firefox, and Safari.

Despite making asynchronous code simpler, dealing with promises in unit tests is a hassle. You need to wire your test’s assertions into the callbacks of the promise, which adds extra code into the test. In this way the test itself becomes a bit complicated and it’s harder to see what’s happening.

In this article, I'll show you how to fix this issue and discuss about useful patterns which are able to simplify common promise-scenarios in tests' stage.

I've created an example project that you can download from my website which shows the techniques introduced in this article.

Getting Started

For this project I'll use Mocha as the testing framework and the Chai library to provide the assertions. You'll understand why in a moment.

Continue reading %Promises in JavaScript Unit Tests: the Definitive Guide%