Key Guidelines to Continuous Integration and Jenkins CI Server

This article was originally published on TestProject — Test Automation Blog. Looking for more on Jenkins and continuous integration? Check out these great links: Screencast: Which Continuous Integration Tools Support Bitbucket? Preparing and Building a PHP Project in Jenkins Continuous Integration with Jenkins Re-Introducing Jenkins: Automated Testing with Pipelines Installing and Securing Jenkins Modern software […]

Continue reading %Key Guidelines to Continuous Integration and Jenkins CI Server%

Source: Sitepoint

Hello, Laravel? Communicating with PHP through SMS!

In this article, we will modify our Laravel-powered phone-capable weather forecast app so that it is accessible via SMS (text message) in addition to the voice telephone system. It is recommended you read the previous post if you haven’t done so yet – it’s a 10 minute read for an excellent outcome.

Note: If you’re confused by the development environment we’re using, it’s Homestead Improved and you can learn more about it here, or go in detail by buying our book about PHP environments.

Vector icon of phone with weather icon overlaid

Adding Routes

To allow for SMS communication, we need some more routes. Open up the routes/web.php file and append the following code to it:

Route::group(['prefix' => 'sms', 'middleware' => 'twilio'], function () {
    Route::post('weather', 'SmsController@showWeather')->name('weather');

The prefix for the route is sms, so that routes will have a path like /sms/weather, as the one in the example. This is the only route we need for SMS, as Twilio will call the same route over and over again. Twilio will access it via HTTP POST. We could also do this without the prefix, but it’s more flexible this way if we decide to add more functionality to the SMS side later.

Service Layer

Next, we’ll modify the service we wrote previously. Open up the app/Services/WeatherService.php file and remove the current getWeather method, then replace it with the one below:

    public function getWeather($zip, $dayName, $forSms = false)

        $point = $this->getPoint($zip);
        $tz = $this->getTimeZone($point);
        $forecast = $this->retrieveNwsData($zip);
        $ts = $this->getTimestamp($dayName, $zip);

        $tzObj = new DateTimeZone($tz->timezoneId);

        $tsObj = new DateTime(null, $tzObj);

        foreach ($forecast->properties->periods as $k => $period) {
            $startTs = strtotime($period->startTime);
            $endTs = strtotime($period->endTime);

            if ($ts > $startTs and $ts < $endTs) {
                $day = $period;

        $weather = $day->name;
        $weather .= ' the ' . $tsObj->format('jS') . ': ';

        $response = new Twiml();

        if ($forSms) {
            $remainingChars = 140 - strlen($weather);

            if (strlen($day->detailedForecast) > $remainingChars) {
                $weather .= $day->shortForecast;
                $weather .= '. High of ' . $day->temperature . '. ';
                $weather .= $day->windDirection;
                $weather .= ' winds of ' . $day->windSpeed;
            } else {
                $weather .= $day->detailedForecast;

        } else {
            $weather .= $day->detailedForecast;

            $gather = $response->gather(
                    'numDigits' => 1,
                    'action' => route('day-weather', [], false)

            $menuText = ' ';
            $menuText .= "Press 1 for Sunday, 2 for Monday, 3 for Tuesday, ";
            $menuText .= "4 for Wednesday, 5 for Thursday, 6 for Friday, ";
            $menuText .= "7 for Saturday. Press 8 for the credits. ";
            $menuText .= "Press 9 to enter in a new zipcode. ";
            $menuText .= "Press 0 to hang up.";

            $gather->say($weather . $menuText);

        return $response;

This function is very similar to the old one. The only difference is that it takes into consideration that the weather request might be coming form a telephone device via SMS, so it makes sure that the weather forecast isn’t too long and tries to limit it to less than 140 characters. The response for SMS is still TwiML, just formatted for SMS.

Continue reading %Hello, Laravel? Communicating with PHP through SMS!%

Source: Sitepoint

Refactor Code in Your Lunch Break: Getting Started with Codemods

Maintaining a codebase can be a frustrating experience for any developer, especially a JavaScript codebase. With ever-changing standards, syntax, and third party package breaking changes, it can be hard to keep up.

In recent years, the JavaScript landscape has changed beyond recognition. Advancements in the core JavaScript language has meant that even the simplest simple task of variable declaration has been changed. ES6 introduced let and const, arrow functions, and many more core changes, each bringing improvements and benefits to developers and their applications.

Pressure on developers to produce and maintain code that will stand up to the test of time is on the increase. This article will show you how you can automate large-scale refactoring tasks with the use of codemods and the JSCodeshift tool, allowing you to easily update your code to take advantage of newer language features, for example.


Codemod is a tool developed by Facebook to help with the refactor of large-scale codebases. It enables the developer to refactor a large codebase in a small amount of time. In some cases, a developer might use an IDE to perform the refactor of a class or variable name, however, this is usually scoped to one file at a time. The next tool in a developer’s refactoring tool kit is a global find and replace. This can work in many cases with the use of complex regular expressions. Many scenarios are not suited to this method; for example, when there are multiple implementations that need to be changed.

Codemod is a Python tool that takes a number of parameters including the expression you wish to match and the replacement.

codemod -m -d /code/myAwesomeSite/pages --extensions php,html 
    '<font *color="?(.*?)"?>(.*?)</font>' 
    '<span style="color: ;"></span>'

In the above example, we are replacing the usage of the <font> tag with a span and inlining the color style. The first two parameters are flags to indicate multiple line matching (-m) and the directory to start processing from (-d /code/myAwesomeSite/pages). We can also restrict the extensions that are processed (–extensions php,html). We then supply the match expression and the replacement. If the replacement is not provided we will be prompted for one at runtime. The tool works, but it is very similar to existing regular expression matching tools.


JSCodeshift is the next step up in the refactor toolkit. Also developed by Facebook, its a tool for running codemods across multiple files. As a Node module, JSCodeshift provides a clean and easy-to-use API, and uses Recast under the hood. Recast is an AST-to-AST (Abstract Syntax Tree) transformation tool.


Recast is a Node module that exposes an interface for parsing and reprinting JavaScript code. It can parse code in string format and generates an object from this which follows an AST structure. This allows us to inspect the code for patterns such as a function declarations.

var recast = require("recast");

var code = [
    "function add(a, b) {",
    "  return a + b",

var ast = recast.parse(code);
    "program": {
        "type": "Program",
        "body": [
                "type": "FunctionDeclaration",
                "id": {
                    "type": "Identifier",
                    "name": "add",
                    "loc": {
                        "start": {
                            "line": 1,
                            "column": 9
                        "end": {
                            "line": 1,
                            "column": 12
                        "lines": {},
                        "indent": 0

As we can see from the above example, we pass in the code string for a function that adds two numbers. When we parse and log the object we can see the AST. We see the FunctionDeclaration and the name of the function etc. As this is just a JavaScript object we can modify it as we see fit. Then we can trigger the print function to return the updated code string.

AST (Abstract Syntax Tree)

As mentioned before, Recast builds an AST from our code string. An AST is a tree representation of the abstract syntax of source code. Each node of the tree represents a construct in the source code and the node provides important information about the construct. ASTExplorer is a browser-based tool that can help to parse and understand the tree of your code.

Using ASTExplorer we can view the AST of a simple code example. Starting with our code, we will declare a const called foo and this will equal the string of ‘bar’.

const foo = 'bar';

This results in the below AST:

Screenshot of the resulting AST

We can see the VariableDeclaration under the body array, which contains our const. All VariableDeclarations have an id attribute that contains our important information such as name etc. If we were building a codemod to rename all instances of foo we can use this name attribute and iterate over all the instances to change the name.

Continue reading %Refactor Code in Your Lunch Break: Getting Started with Codemods%

Source: Sitepoint

How to Apply CSS3 Transforms to Background Images

CSS3 Transforms on Background Images

Updated version of article published on September 27, 2012. Updates include latest data on current browser support, removing unnecessary vendor prefixes from code samples, and addition of live demo on CodePen.

Scaling, skewing and rotating any element is possible with the CSS3 transform property. It’s supported in all modern browsers without vendor prefixes. If you need to support Blackberry Browser and UC Browser for Android, you’ll need to use the -webkit- prefix, e.g.

[code language=”css”]
#myelement {
-webkit-transform: rotate(30deg);
transform: rotate(30deg);

Great stuff. However, this rotates the whole element — its content, border and background image. What if you only want to rotate the background image? Or what if you want the background to remain fixed while the element is rotated?

Currently, there’s no W3C proposal for background-image transformations. It would be incredibly useful so I suspect one will appear eventually, but that doesn’t help developers who want to use similar effects today.

Fortunately, there is a solution. In essence, it’s a hack which applies the background image to a before or after pseudo element rather than the parent container. The pseudo element can then be transformed independently.

Transforming the Background Only

The container element can have any styles applied but it must be set to position: relative since our pseudo element will be positioned within it. You should also set overflow: hidden unless you’re happy for the background to spill out beyond the container.

[code language=”css”]
#myelement {
position: relative;
overflow: hidden;

We can now create an absolutely-positioned pseudo element with a transformed background. The z-index is set to -1 to ensure it appears below the container’s content.

[code language=”css”]
#myelement:before {
content: “”;
position: absolute;
width: 200%;
height: 200%;
top: -50%;
left: -50%;
z-index: -1;
background: url(background.png) 0 0 repeat;
-webkit-transform: rotate(30deg);
transform: rotate(30deg);

Note you may need to adjust the pseudo element’s width, height and position. For example, if you’re using a repeated image, a rotated area must be larger than its container to fully cover the background:

CSS3 transformation on background

Fixing the Background on a Transformed Element

Continue reading %How to Apply CSS3 Transforms to Background Images%

Source: Sitepoint

Adding a Contextual Help Tab to Custom Post Type Screens

That little “Help” tab that sits in the top-right corner of the WordPress admin dashboard which, when clicked, reveals helpful information about the various admin pages and how they work is referred to as a contextual help tab. It is contextual because the information it displays pertains to the admin page that is currently being […]

Continue reading %Adding a Contextual Help Tab to Custom Post Type Screens%

Source: Sitepoint

How to Build a Virtual Design Team with 99designs

99designs is an on-demand marketplace where companies seek to find their dream design by running design contests (anything from business cards, to logos, to websites…I could go on). Many companies also use 99designs to curate their own on-call virtual design team. Think: The Avengers, but for teams of super-designers handpicked by you.

Projects” is useful for large or unexpected campaigns with tight deadlines, where agencies have the benefit of being able to access the best talent — quickly, easily, and securely. Let’s take a look at how that works exactly.

Step 1: Discovering Designers

Finding your dream designer (or dream team of designers) is the first step. Begin by navigating to /discover (link in the menu), where you’ll see an endless list of stunning designs. Your designer is here, somewhere. Let’s find them.

Discovering new designers

Next, click “Show Filters” (on the right-hand side) so that we can narrow our search a little bit — these filters are instrumental in refining the relevancy of your search result. We’re getting closer, our first designer isn’t too far away.

How to find a designer

Let’s see how smart these filters are:

  • Categories: choose which type of designs you need (you can choose anything from book covers to Facebook covers!)
  • Industries: many designers specialise in a certain industry (i.e. restaurants, technology, cosmetics and beauty, etc)
  • Search: add specific keywords to your search
  • Advanced: narrow your search even further by finding designers that speak a specific language, or specifically limit your options to Platinum designers, or those have won contests

Platinum designers are those that have been handpicked by 99designs. These are designers that have won numerous design contests and have demonstrated the highest caliber of conceptual thought and technical execution. Platinum designers go far beyond generic designs, and have a thorough understanding of typography, visual hierarchy, composition and colour, and use these skills to meet the client’s specific needs. These guys are like the Captain America’s of design teams.

Activating the search filters

When you’ve discovered a design that you like (you’ll probably find several, actually!), click on it to find out who the designer is. From here you can read about the story behind the design itself (the best designers talk about their work passionately, and with plenty of enthusiasm!) and also view the designer’s profile.

Viewing a designer's profile

You don’t need to be a detective to learn more about the designer — use the tabs on the left-hand side to see more of their work, what experience they have in certain fields, read reviews from previous clients, and finally, browse through the list of pre-made design packages that the designer offers. It’s really, really easy — and pleasantly transparent.

Viewing a designer's portfolio

Step 2: Building Your Virtual Design Team

When you think you’ve matched with the right designer, click the “Invite to work” button (on the right-hand side), where you’ll either be able to choose one of those pre-made packages, or discuss your custom needs. Alternatively, click the favourite icon (next to the designer’s name) to add them to your favourites, where you can then reach out at a later date.

Continue reading %How to Build a Virtual Design Team with 99designs%

Source: Sitepoint

Creating a Grocery List Manager Using Angular, Part 2: Managing Items

In the first part of this Angular tutorial series, you saw how to get started with creating a Grocery List Manager using Angular. You learnt how to create the view for the Grocery component, adding items to the grocery list and displaying the added items.

In this part, you’ll implement the features to mark completed items, edit existing items, and remove added items.

Getting Started

Let’s get started by cloning the source code from the first part of the tutorial. From your terminal, write in the following code to clone the source code:

Once the source code has been cloned, navigate to the project folder and install the required dependencies.

After installing the dependencies, you will be able to start the server. From the project folder, type in the following commands:

Point your browser to http://localhost:4200/ and you should have the application running.

Updating Grocery Items

Once you have the grocery items added to the list, you should be able to edit and update the items. Let’s provide an edit button in the listing grid which, when clicked, will enable the editing of existing items.

Modify the code to include the edit button inside the grid.

Save the above changes and restart the server. Load the page and enter a few items and you will have the edit button for each item.

Grocery List Manager - Edit Button

When the user clicks the edit button, you need to add an on click method to handle the item edit. Modify the to add an on click event for editing the item.

Pass the task to the onEdit method as shown in the above code to identify the item to be edited.

Inside the GroceryComponent class initialize the task scope variable as shown:

In the onClick method, you’ll check for the id to see if it’s an existing item or a new item. Modify the onClick method as shown:

As seen, you have assigned a unique time stamp as id to each task. Now let’s define the onEdit method to edit the existing item. Inside the onEdit method, assign the passed in item to the task variable.

Save the changes and restart the server. Enter a new item in the grocery list and click on the corresponding edit button. You will be able to edit and update the entry by clicking the OK button.

Grocery List Manager - Edit and Update

Deleting Grocery Items

Let’s add a delete icon to remove the existing items. Update the file to modify the HTML code as shown:

Here is how the complete file looks:

Add an on click event to the remove icon to delete the grocery item.

Save the changes and restart the server. Try adding new items to the grocery manager app and you will have the items listed along with the delete and edit icons.

Grocery List Manager App - Delete View

To implement the delete functionality, you need to add the onDelete method in the file as shown:

Once the user clicks the delete icon, you need to check the item id against the grocery item list and remove the entry from the tasks list. Here is how the onDelete method looks:

As seen in the above code, you have iterated the tasks list and checked it against the clicked item id. If it matched the item in the tasks list, it is removed using the splice method.

Save the above changes and restart the server. Add a few items to the grocery list manager. It will be added with the delete and edit icons to the task list grid. Try clicking on the remove icon and the item will be deleted from the items list.

Marking the Grocery Item as Done

Let’s add the functionality to strike out the items added to the list. Once the user is done with the tasks in the grocery list manager, it should be possible to strike out the completed tasks. To track the new and completed tasks, add a new variable strike to the task information. 

Modify the onClick method to include the new strike variable as shown:

Add a new class called strike in the src/style.css file which would strike out the item.

Include an on click event on the item to toggle the strike variable in the items variable. You’ll be applying the strike class to the items based on the boolean value of the strike variable. By default, it will be false. Here is the onStrike method to toggle the strike variables value:

As seen in the above method, you iterate through the list of items. Once the item is found, you toggle the strike value.

Based on the strike variable, you need to apply the class strike to the task name span. Here is how it looks:

As seen, you have used the ngClass directive to apply the class strike to the span element if the task.strike value is true.

Save the above changes and restart the server. Add the items to the list and click on the added item. Once clicked, the item will be struck out as expected.

Grocery List Manager - Strike Out Completed Task

Wrapping It Up

In this tutorial, you saw how to update, delete and mark the task as complete in the grocery manager app using Angular. I hope you enjoyed the tutorial. Do let me know your thoughts in the comments below.

JavaScript has become one of the de facto languages of working on the web. It’s not without its learning curves, and there are plenty of frameworks and libraries to keep you busy, as well. If you’re looking for additional resources to study or to use in your work, check out what we have available in the Envato marketplace.

Oh, and don’t forget that the source code from this tutorial is available on GitHub.

Source: Nettuts Web Development

Using Celery With Django for Background Task Processing

Web applications usually start out simple but can become quite complex, and most of them quickly exceed the responsibility of only responding to HTTP requests.

When that happens, one must make a distinction between what has to happen instantly (usually in the HTTP request lifecycle) and what can happen eventually. Why is that? Well, because when your application becomes overloaded with traffic, simple things like this make the difference. 

Operations in a web application can be classified as critical or request-time operations and background tasks, the ones that happen outside request time. These map to the ones described above: 

  • needs to happen instantly: request-time operations
  • needs to happen eventually: background tasks

Request-time operations can be done on a single request/response cycle without worrying that the operation will time out or that the user might have a bad experience. Common examples include CRUD (Create, Read, Update, Delete) database operations and user management (Login/Logout routines).

Background tasks are different as they are usually quite time-consuming and are prone to failure, mostly due to external dependencies. Some common scenarios among complex web applications include:

  • sending confirmation or activity emails
  • daily crawling and scraping some information from various sources and storing them
  • performing data analysis
  • deleting unneeded resources
  • exporting documents/photos in various formats

Background tasks are the main focus of this tutorial. The most common programming pattern used for this scenario is the Producer Consumer Architecture. 

In simple terms, this architecture can be described like this: 

  • Producers create data or tasks.
  • Tasks are put into a queue that is referred to as the task queue. 
  • Consumers are responsible for consuming the data or running the tasks. 

Usually, the consumers retrieve tasks from the queue in a first-in-first-out (FIFO) fashion or according to their priorities. The consumers are also referred to as workers, and that is the term we will be using throughout, as it is consistent with the terminology used by the technologies discussed.

What kind of tasks can be processed in the background? Tasks that:

  • are not essential for the basic functionality of the web application
  • can’t be run in the request/response cycle since they are slow (I/O intensive, etc.)
  • depend on external resources that might not be available or not behave as expected
  • might need to be retried at least once
  • have to be executed on a schedule

Celery is the de facto choice for doing background task processing in the Python/Django ecosystem. It has a simple and clear API, and it integrates beautifully with Django. It supports various technologies for the task queue and various paradigms for the workers.

In this tutorial, we’re going to create a Django toy web application (dealing with real-world scenarios) that uses background task processing.

Setting Things Up

Assuming you are already familiar with Python package management and virtual environments, let’s install Django:

I’ve decided to build yet another blogging application. The focus of the application will be on simplicity. A user can simply create an account and without too much fuss can create a post and publish it to the platform. 

Set up the quick_publisher Django project:

Let’s get the app started:

When starting a new Django project, I like to create a main application that contains, among other things, a custom user model. More often than not, I encounter limitations of the default Django User model. Having a custom User model gives us the benefit of flexibility.

Make sure to check out the Django documentation if you are not familiar with how custom user models work.

Now we need to tell Django to use this User model instead of the default one. Add this line to the quick_publisher/ file:

We also need to add the main application to the INSTALLED_APPS list in the quick_publisher/ file. We can now create the migrations, apply them, and create a superuser to be able to log in to the Django admin panel:

Let’s now create a separate Django application that’s responsible for posts:

Let’s define a simple Post model in publisher/

Hooking the Post model with the Django admin is done in the publisher/ file like this:

Finally, let’s hook the publisher application with our project by adding it to the INSTALLED_APPS list.

We can now run the server and head over to http://localhost:8000/admin/ and create our first posts so that we have something to play with:

I trust you’ve done your homework and you’ve created the posts. 

Let’s move on. The next obvious step is to create a way to view the published posts. 

Let’s associate our new view with an URL in: quick_publisher/

Finally, let’s create the template that renders the post in: publisher/templates/post.html

We can now head to http://localhost:8000/the-slug-of-the-post-you-created/ in the browser. It’s not exactly a miracle of web design, but making good-looking posts is beyond the scope of this tutorial.

Sending Confirmation Emails

Here’s the classic scenario:

Let’s add an is_verified flag and the verification_uuid on the User model:

Let’s use this occasion to add the User model to the admin:

Let’s make the changes reflect in the database:

We now need to write a piece of code that sends an email when a user instance is created. This is what Django signals are for, and this is a perfect occasion to touch this subject. 

Signals are fired before/after certain events occur in the application. We can define callback functions that are triggered automatically when the signals are fired. To make a callback trigger, we must first connect it to a signal.

We’re going to create a callback that will be triggered after a User model has been created. We’ll add this code after the User model definition in: main/

What we’ve done here is we’ve defined a user_post_save function and connected it to the post_save signal (one that is triggered after a model has been saved) sent by the User model.

Django doesn’t just send emails out on its own; it needs to be tied to an email service. For the sake of simplicity, you can add your Gmail credentials in quick_publisher/, or you can add your favourite email provider. 

Here’s what Gmail configuration looks like:

To test things out, go into the admin panel and create a new user with a valid email address you can quickly check. If all went well, you’ll receive an email with a verification link. The verification routine is not ready yet. 

Here’s how to verify the account:

Hook the views up in: quick_publisher/

Also, remember to create a home.html file under main/templates/home.html. It will be rendered by the home view.

Try to run the entire scenario all over again. If all is well, you’ll receive an email with a valid verification URL. If you’ll follow the URL and then check in the admin, you can see how the account has been verified.

Sending Emails Asynchronously

Here’s the problem with what we’ve done so far. You might have noticed that creating a user is a bit slow. That’s because Django sends the verification email inside the request time. 

This is how it works: we send the user data to the Django application. The application creates a User model and then creates a connection to Gmail (or another service you selected). Django waits for the response, and only then does it return a response to our browser. 

Here is where Celery comes in. First, make sure it is installed:

We now need to create a Celery application in our Django application:

Celery is a task queue. It receives tasks from our Django application, and it will run them in the background. Celery needs to be paired with other services that act as brokers. 

Brokers intermediate the sending of messages between the web application and Celery. In this tutorial, we’ll be using Redis. Redis is easy to install, and we can easily get started with it without too much fuss.

You can install Redis by following the instructions on the Redis Quick Start page. You’ll need to install the Redis Python library, pip install redis, and the bundle necessary for using Redis and Celery: pip install celery[redis].

Start the Redis server in a separate console like this: $ redis-server

Let’s add the Celery/Redis related configs into quick_publisher/

Before anything can be run in Celery, it must be declared as a task. 

Here’s how to do this:

What we’ve done here is this: we moved the sending verification email functionality in another file called

A few notes:

Going back to main/, the signal code turns into:

Notice how we call the .delay method on the task object. This means we’re sending the task off to Celery and we don’t wait for the result. If we used send_verification_email( instead, we would still be sending it to Celery, but would be waiting for the task to finish, which is not what we want.

Before you start creating a new user, there’s a catch. Celery is a service, and we need to start it. Open a new console, make sure you activate the appropriate virtualenv, and navigate to the project folder.

This starts four Celery process workers. Yes, now you can finally go and create another user. Notice how there’s no delay, and make sure to watch the logs in the Celery console and see if the tasks are properly executed. This should look something like this:

Periodic Tasks With Celery

Here’s another common scenario. Most mature web applications send their users lifecycle emails in order to keep them engaged. Some common examples of lifecycle emails:

Here’s what we’re going to do in our app. We’re going to count how many times every post has been viewed and send a daily report to the author. Once every single day, we’re going to go through all the users, fetch their posts, and send an email with a table containing the posts and view counts.

Let’s change the Post model so that we can accommodate the view counts scenario.

As always, when we change a model, we need to migrate the database:

Let’s also modify the view_post Django view to count views:

It would be useful to display the view_count in the template. Add this <p>Viewed {{ post.view_count }} times</p> somewhere inside the publisher/templates/post.html file. Do a few views on a post now and see how the counter increases.

Let’s create a Celery task. Since it is about posts, I’m going to place it in publisher/

Every time you make changes to the Celery tasks, remember to restart the Celery process. Celery needs to discover and reload tasks. Before creating a periodic task, we should test this out in the Django shell to make sure everything works as intended:

Hopefully, you received a nifty little report in your email. 

Let’s now create a periodic task. Open up quick_publisher/ and register the periodic tasks:

So far, we created a schedule that would run the task publisher.tasks.send_view_count_report every minute as indicated by the crontab() notation. You can also specify various Celery Crontab schedules

Open up another console, activate the appropriate environment, and start the Celery Beat service. 

The Beat service’s job is to push tasks in Celery according to the schedule. Take into account that the schedule makes the send_view_count_report task run every minute according to the setup. It’s good for testing but not recommended for a real-world web application.

Making Tasks More Reliable

Tasks are often used to perform unreliable operations, operations that depend on external resources or that can easily fail due to various reasons. Here’s a guideline for making them more reliable:


I hope this has been an interesting tutorial for you and a good introduction to using Celery with Django. 

Here are a few conclusions we can draw:

Source: Nettuts Web Development

Top Ten New Development Tools of the Month, June 2017

Top Ten New Development Tools of the Month

You can never have enough tools. There’s always a better way to achieve the same result no matter how slick your development process becomes!

Welcome to a new, regular series of articles that list the top ten new development tools of the month, as collated by StackShare. StackShare uses a combination of community feedback from discussions, favorites, up-votes, and stacks (tool collections) to determine the popularity of each new tool.

Looking for more on development tools or resources for learning development? Check out these great links:

The top ten new development tools for June 2017 are:

1. osquery – OS SQL Query Tool

At number #1 is osquery – a new tool from Facebook which exposes your Windows, macOS or Linux operating system as a relational database. You can use SQL queries to examine running processes, view installed software, discover hardware events and more.

The following example returns a list of attached USB hardware devices:

select * from usb_devices;

It’s an unusual idea. It could be used by web developers to monitor performance or security breaches regardless of where an application is hosted or their experience of that platform.

More information and downloads:

2. Standup – Progress Reporting Service

Standup processes your project data from services including GitHub, Bitbucket, GitLab, Jira and Trello to create development team progress reports in a single view. The online service is free to use, easy to understand, and could streamline your daily stand-up meetings.

More information and sign-up:

3. Draft – Container Development Tool

Draft is an experimental tool which helps developers build applications that run on Kubernetes containers. It’s currently available on Linux and macOS, with Windows builds coming soon.

More information and downloads:

Continue reading %Top Ten New Development Tools of the Month, June 2017%

Source: Sitepoint

How to Create Interactive JavaScript Charts from Custom Data Sets

Charts are a great way of visualizing complex data quickly and effectively. Whether you want to identify a trend, highlight a relationship, or make a comparison, charts help you communicate with your audience in a precise and meaningful manner.

In my previous article — Getting Started with AnyChart: 10 Practical Examples — I introduced the AnyChart library and demonstrated how it is a great fit for your data visualization needs. Today, I want to dig a little deeper and look at AnyChart’s data mapping features which allow you to create beautiful charts from custom data sets with a minimum of fuss.

I also want to look at the many ways you can customize AnyChart to suit your requirements, as well as how you can change the look and feel of AnyChart charts by using themes. There are currently 17 out-of-the-box themes to choose from, or you can create your own. And if you’ve not got the best eye for design, why not buy our book to get a leg up.

As the Head of R&D at AnyChart, I could spend all day talking about this library, but now it’s time to get down to business.

Data Mapping in AnyChart

To facilitate the integration of custom data sources into charting applications, AnyChart has special objects called data sets. These objects act as intermediate containers for data. When data is stored in data sets, AnyChart can track changes to it, analyze it, and work with this data in a more robust and effective manner. In short: interactive JavaScript charts have never been easier!

No matter if you have an array of objects, an array of arrays, or a .csv file, you can use data sets to:

  • ensure full and explicit control over the series created
  • define which column is an argument (x-axis)
  • define which columns hold values for which series
  • filter data
  • sort data

Basics of Data Mapping

The best way to learn how data mapping works in AnyChart is to look at an example. Let’s imagine an array with the following custom data set:

var rawData = [
  ["A", 5, 4, 5, 8, 1, "bad"],
  ["B", 7, 1, 7, 9, 2, "good"],
  ["C", 9, 3, 5, 4, 3, "normal"],
  ["D", 1, 4, 9, 2, 4, "bad"]

There’s nothing too wild going on here — this kind of custom data structure is common in a lot of existing applications. But now you want to use this array in AnyChart. With many other charting libraries you would be forced to transform the data to a format that the library can work with. Well, with AnyChart things are a lot simpler — just look what we can do. First, load the array into a data set:

var rawData = [
  ["A", 5, 4, 5, 8, 1, "bad"],
  ["B", 7, 1, 7, 9, 2, "good"],
  ["C", 9, 3, 5, 4, 3, "normal"],
  ["D", 1, 4, 9, 2, 4, "bad"]

var dataSet =;

And then, once the data has been loaded into the data set, the real magic begins: you can now create so called views. These are data sets derived from other data sets.

var rawData = [
  ["A", 5, 4, 5, 8, 1, "bad"],
  ["B", 7, 1, 7, 9, 2, "good"],
  ["C", 9, 3, 5, 4, 3, "normal"],
  ["D", 1, 4, 9, 2, 4, "bad"]

var dataSet =;

var view1 = dataSet.mapAs({x: 0, value: 1});
var view2 = dataSet.mapAs({x: 0, value: 2});
var view3 = dataSet.mapAs({x: 0, high: 3, low: 4});
var view4 = dataSet.mapAs({x: 0, value: 5, meta: 6});

You’ll notice that when defining a view, you determine which columns from the original array are included and what names these columns get. You can then use them to create whichever kind of charts you like. For example, here’s how to create a pie chart from the custom data in the 5th column.

Note: AnyChart needs only x and value fields to create a pie chart, but the views also contain a meta field with the data from the 6th column. You can map any number of optional fields and use them as you like. For example, these fields can contain additional data to be shown as labels or as tooltips:

anychart.onDocumentLoad(function() {
  var rawData = [
    ["A", 5, 4, 5, 8, 3, "Bad"],
    ["B", 7, 1, 7, 9, 5, "Good"],
    ["C", 9, 3, 5, 4, 4, "Normal"],
    ["D", 1, 4, 9, 2, 3, "Bad"]

  var dataSet =;
  var view4 = dataSet.mapAs({x: 0, value: 5, meta: 6});

  // create chart
  var chart = anychart.pie(view4);
  chart.title("AnyChart: Pie Chart from Custom Data Set");
  chart.labels().format("{%meta}: {%Value}");

And this is what we end up with:

See the Pen AnyChart Pie Chart from Data Set by SitePoint (@SitePoint) on CodePen.

Note: You can find all of the demos in this article as a CodePen collection.

Multi-Series Combination Chart with Custom Data Set

Now, let’s see how we can use the same custom data to create a combination chart with line and range area charts on the same plot. This section is going to be very short since now you know what views are. All you need to do is choose the proper views and create the necessary series explicitly:

anychart.onDocumentLoad(function() {
  var rawData = [
    ["A", 5, 4, 5, 8, 3, "Bad"],
    ["B", 7, 1, 7, 9, 5, "Good"],
    ["C", 9, 3, 5, 4, 4, "Normal"],
    ["D", 1, 4, 9, 2, 3, "Bad"]

  var dataSet =;

  var view1 = dataSet.mapAs({x: 0, value: 1});
  var view2 = dataSet.mapAs({x: 0, value: 2});
  var view3 = dataSet.mapAs({x: 0, high: 3, low: 4});

  // create chart
  var chart = anychart.line();
  // create two line series
  // create range area series

  // set title and draw chart
  chart.title("AnyChart: Combined Chart from Data Set");

This is what it looks like:

See the Pen AnyChart Combined Chart from Data Set by SitePoint (@SitePoint) on CodePen.

Continue reading %How to Create Interactive JavaScript Charts from Custom Data Sets%

Source: Sitepoint