Thursday, April 7, 2016

Launch Your Startup and Make Millions

Launch your startup and make millions—this $49 bundle will teach you how

Got a business idea? We’ve got a course bundle that will handle the rest. Get the Startup School 2016 Bundle for $49 at SitePoint Shop.

You’ll save 97% off the regular price of $1,931 when you grab this bundle at SitePoint Shop. The 10 courses inside will teach you everything you need to know about starting a business and making it successful. Pick up key marketing techniques, learn how to create a strong online presence, find out how to win over investors, master outsourcing to save money and time, and get more productive than ever with tips and tools that successful entrepreneurs rely on. Your instructors have experience building brick-and-mortar businesses, launching cloud-based companies, and making thousands every month from their ideas.

Get started. Get the Startup School 2016 Bundle for $49 at SitePoint Shop.

Continue reading %Launch Your Startup and Make Millions%


by SitePoint Offers via SitePoint

How to Work With JSON Data Using Python

This tutorial shows how easy it is to use the Python programming language to work with JSON data.

Before I begin the topic, let's define briefly what we mean by JSON. Let's see how JSON's main website defines it:

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming LanguageStandard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

Thus, JSON is a simple way to create and store data structures within JavaScript. The reason you see JavaScript in the acronym is due to the fact that a JavaScript object is created when storing data with JSON. But, don't worry, you don't need to know JavaScript to work with JSON files, rather it is about the JSON syntax (format) itself.

In brief, JSON is a way by which we store and exchange data, which is accomplished through its syntax, and is used in many web applications. The nice thing about JSON is that it has a human readable format, and this may be one of the reasons for using it in data transmission, in addition to its effectiveness when working with APIs.

An example of JSON-formatted data is as follows:

In this tutorial, I will show you how to use Python to work with JSON files. So, let's get started!

Python and JSON

Python makes it simple to work with JSON files. The module used for this purpose is the json module. This module should be included (built-in) within your Python installation, and you thus don't need to install any external modules as we did when working with PDF and Excel files, for instance. The only thing you need in order to use this module is to import it:

import json

But, what does the json library do? This library mainly parses JSON from files or strings. It also parses JSON into a dictionary or list in Python and vice versa, that is converting a Python dictionary or list into JSON strings.

JSON to Python

Reading JSON means converting JSON into a Python value (object). As mentioned above, the json library parses JSON into a dictionary or list in Python. In order to do that, we use the loads() function (load from a string), as follows:

If you want to see the output, do a print jsonToPython, in which case you will get the following output:

{u'age': 39, u'name': u'Frank'}

That is, the data is returned as a Python dictionary (JSON object data structure). So, will the statement print jsonToPython['name'] return any output? Go ahead, try it out.

Python to JSON

In the previous section, we saw how to convert JSON into a Python value (i.e. Dictionary). In this section, I will show you how we can convert (encode) a Python value to JSON.

Say that we have the following Dictionary in Python:

If we print dictionaryToJson, we get the following JSON data:

{"age": 44, "isEmployed": true, "name": "Bob"}

So this output is considered the data representation of the object (Dictionary). The method dumps() was the key to such operation.

It is important to note at this point that JSON cannot store all types of Python objects, but only the following types: Lists; Dictionaries; Booleans; Numbers; Character strings; and None. Thus, any other types need to be converted in order to be stored in JSON.

Let's say we have the following class:

Let's say we created a new object abder, as follows:

abder = Employee('Abder')

What if we wanted to convert this object to JSON? That is json.dumps(abder)? In this case, you would get an error similar to the following:

But, is there a workaround? Fortunately there is. I like the workaround described on the Python Tips website. To solve this issue, we can define a method similar to the following:

Then encode the object into JSON as follows:

jsonAbder = json.dumps(abder, default=jsonDefault)

If you print jsonAbder, you should get the following output:

{"name": "Abder"}

We have now encoded a Python object (abder) into JSON.

Conclusion

From this tutorial, we can notice that Python again and again is proving not only its ability to work with different applications, but also its flexibility to work with different issues while working with an application, as we saw in the last part of the tutorial.

If you want to know more about the json module, you can visit the documentation page.


by A. Ahmed via Envato Tuts+ Code

Gutenberg

opl-small

One Pager promoting a new CSS framework by Matej Latin called 'Gutenberg' that focuses on clean web typography. Nice feature that turns on the grid to visualise how it works within the page you are reading.

by Rob Hope via One Page Love

Popper.js – Create Tooltips and Popovers in Web Applications

Popper.js is a library used to create poppers in web applications. Common examples of poppers are tooltips and popovers.


by via jQuery-Plugins.net RSS Feed

WordPress Actions and Filters: What's the Difference?

Action and filter hooks are a fundamental part of the various WordPress APIs. Without them you're limited as to what you can do in your themes and (especially) your plugins.

But sometimes it can be easy to confuse the two, especially in the cases when WordPress has both an action hook and a filter hook with the same name.

In this article I'll define action and filter hooks and describe the difference between them, and I'll demonstrate how to use them in your themes and plugins. I'll also give some examples of when you might use each.

When you're adding action and filter hooks to your code (or you're hooking functions to them), it helps to understand how actions and filters are called by WordPress and what happens in what order. I won't cover that in detail here as we have another tutorial that does that job.

Definitions and Differences

Let's start with some definitions. I'll define action and filter hooks and functions too, so you can see the difference between them all.

Functions

Functions are the first thing most people work with when they're learning WordPress development; if you've added code to your theme's functions.php file, then you'll have written a function.

Functions specify how something will happen. You code a function to query data, to output content, or to perform many other tasks. You can call (execute) functions directly in your theme's template files, or you can hook them to action or filter hooks. Functions can also include template tags such as conditional tags, to specify when the function should apply.

I'll show you the different ways to execute functions later in this article.

Action Hooks

Action hooks (or actions) are triggered when something takes place, such as loading a page, a user logging in, or a custom action that you define in your theme or plugin.

You can add your own action hooks using the do_action() function, which I'll demonstrate shortly. Any functions you hook to that action will then run at that point in the code.

Filter Hooks

Filter hooks, or filters, control how something happens or change something that's already being output. You could use a filter to output metadata in a specific format, to override text output by your plugin, or to prevent something from being displayed at all.

You add filters in your code using the apply_filters() function, which I'll demonstrate shortly. As the word 'apply' indicates, you apply filters to existing code, whereas an action you create using do_action() is empty until you hook functions to it.

Using Functions, Actions, and Filters

Let's take a look at some examples demonstrating how you use each of functions, actions, and filters. First, we'll look at using functions directly in your code without attaching them to a hook.

Calling Functions Directly

Here's an example of a function that's called directly in a template file. In my client sites I add a colophon in the footer, which includes copyright information. Here's the function:

This function is pluggable as I use it in a parent theme; if I then create a new function with the same name in my child theme, that will override this function. Note that the function includes another function, compass_colophon(), calling it directly in the code.

This function is in the functions.php file of my parent theme. I can call it directly in the footer.php file of my theme, like so:

This outputs the code in the function at the point in my theme where I call it. You can also pass parameters to your functions, which are then used inside the function.

As I'll demonstrate shortly, this function could also be hooked to an action or a filter.

Hooking Functions to Actions

Rather than calling that colophon function directly, I'll have more flexibility if I attach it to a hook.

Creating Action Hooks

Instead of calling the compass_colophon() function in my footer file, I can add an action hook at that point in the footer.php file, by adding this:

The do_action() function has one mandatory parameter, which is the name of the action. You can also optionally add arguments to it.

Hooking Functions to Actions

So now instead of calling my colophon function, I need to hook it to my new action hook. In my functions.php file, I add this with my function:

This hooks my function to the compass_in_footer action, which means that the code inside my function will run at the point in the code where the action has been placed. The first parameter is the name of the action hook, and the second is the name of my function.

An advantage of doing it this way is that you can hook more than one function to the same action, and you can set the priority so they fire in the order you want them to.

So let's say I have another function I want to hook to my compass_in_footer hook, called compass_smallprint(), which contains some more small print:

You can see here that I've added a third parameter to my add_action() function, which is the priority. The default priority is 10, which will be applied if you leave this blank. So because I haven't set a priority for my compass_colophon() function, setting 20 for the compass_smallprint() function will make that function run after the compass_colophon() function.

Unhooking Functions From Actions

Sometimes you want to stop a function from running, and you can't override it because it's not pluggable. If the function has been hooked to an action hook, then you can do this using the remove_action() function.

So if I want to prevent my compass_smallprint() function from running, I unhook it from the compass_in_footer action like so:

The remove_action() function has three parameters: the name of the action hook, the name of the function, and the priority with which the function was originally hooked to the action. You must include the priority for this to work.

You can also unhook all of the functions from an action if you want to prevent them all from executing. Be careful when doing this, as there may be functions you're not aware of hooked to your action.

To do this, use the remove_all_actions() function:

Adding a priority number as the second parameter only removes the functions which are hooked to that action hook with the priority you've specified, which gives you more control.

Hooking Functions to Filters

You also have the option of hooking your functions to filter hooks. You do this when you want to alter or override some existing code. When you create the filter hook (using the apply_filters() function), you wrap that around code in your theme or plugin, which is then altered by any filters attached to the hook.

This can be useful if you have theme or plugin options that you want to override a default setting, or if you're creating a parent theme that may have elements overridden by a child theme.

Creating Filter Hooks

The apply_filters() function has three parameters: the name of the filter hook, the value which you want to filter (i.e. the default value), and optional variables which you then pass to the functions hooked to the filter.

You can add a filter in your theme template files or inside a function that is hooked via an action hook. Let's take a look at both options.

Returning to my compass_colophon() function, I convert this to a filter by adding its contents to my footer.php file inside the apply_filters() function like so:

This outputs the code that I've set as the second parameter of my apply_filters() function.

However, I prefer not to add this directly to my theme template file, so I'll add the filter to the function that I'm already attaching via an action hook.

So I add the compass_in_footer action to my footer.php file using the do_action() function as demonstrated above, and then I create a function in my functions.php file which is hooked to that action and contains a filter:

This means that I can now override the default content in one of three ways:

  • by creating a new function called compass_colophon() in my child theme, which overrides the function in my parent theme as that's pluggable
  • by unhooking the compass_colophon() function from the compass_in_footer action hook and writing a new function which I attach to it in its place
  • by creating a new function which I then hook to the compass_colophon_filter filter hook, which overrides the value in my apply_filters() function

In real life you wouldn't need to have this many options, so it's more likely that you'd apply filters to part of the content in your function rather than the whole thing.

So I could create two filters, one for the copyright section and another for the credits:

Then I could either override the whole of my compass_colophon function by unhooking it or writing a new one in my child theme, or I could create a function hooked to the compass_copyright_filter or compass_credits_filter filter hook, to override each element individually.

Hooking Functions to Filters

To hook a function to a filter hook, you use the add_filter() function, which has two parameters: the name of the hook and the name of the function.

So to change the credits, I would write this function:

This overrides the value set in my original compass_credits_filter filter hook with the content of my new_credits() function, but keeps everything else in the compass_colophon() function the same.

You can also specify priorities when hooking functions to filters, in exactly the same way as with action hooks. Functions with a lower priority will be run first.

Unhooking Functions From Filters

As with action hooks, you can also remove functions from filter hooks. You do this using the remove_filter() function, which has three parameters: the name of the filter hook, the name of the function, and the priority, which is mandatory if a priority was set when the function was originally hooked to the filter.

So to remove my new_credits() function, I use this:

The code output would then revert to the value I specified in my original apply_filters() function. So if I wanted to remove the new_credits() function and have nothing appear in its place, I'd have to add a new function. I then unhook the first function and hook my new function like so:

Summary

Understanding the difference between action and filter hooks and being able to use both of them effectively will give your theme and plugin development a boost. In fact, without using hooks of at least one type, you can't write plugins at all, as the only way the code in your plugins is activated is via the action and filter hooks it's attached to.

This guide showed you how to add the same functionality using a function, an action hook and one or more filter hooks, along with techniques for removing functions from hooks and advice on when each technique is more useful.

As well as hooking functions to your own action and filter hooks that you create, you can hook them to the actions and filters provided by WordPress, such as the wp_head action or the body_class filter.


by Rachel McCollin via Envato Tuts+ Code

4 Ways to Save Time With Social Media Marketing Tools

cj-social-media-tools-560

Do you spend too much time adding customer data to spreadsheets? Looking for ways to automate some of your marketing tasks? If you’re creating content for a target audience, automated tools can free up your time to engage as a human when and where it matters most. In this article you’ll discover four ways to [...]

This post 4 Ways to Save Time With Social Media Marketing Tools first appeared on .
- Your Guide to the Social Media Jungle


by Cynthia Johnson via

The “Most Loved” One Page Websites in March – presented by BlueHost

one-page-love-hosting-reviews-bh-unlimitedMarch’s “Most Loved” One Page website round-up is brought to you by hosting provider, BlueHost.

Blue Host is the affordable hosting option to host your One Page website. Pricing starts at only $3.49/month where you can host your website with 100GB diskspace and bandwidth. Next tier up is $5.95/month where you can have unlimited sites, disk space and bandwidth! They are very web established and have a huge support team 24-7. Learn more about BlueHost.

If you want to receive these “Most Loved” awards in your inbox each month, subscribe to our Inspiration Newsletter.

Below are 8 One Page websites we awarded “Most Loved” in March – hope you enjoy!


Benjamin Guedj (Portfolio)

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

Launch Website
Full Review


56 (Portfolio)

Great vibe portrayed in this long scrolling One Page portfolio for Toronto-based design studio, 56. Couple really nice touches in this site; the initial load transitions with the 3D hover sensitive background pattern, the hand icon that changes direction as you scroll up and down, the whole site color scheme adaption to align with the current project you’re browsing, the funny tagline that randomly changes and the META title tag that keeps changing it’s algorithm but always equals to 56:)

Launch Website
Full Review


Freewrite (Product, Launching Soon)

Awesome parallax scrolling One Pager filled with fun custom illustrations and animations for a new “smart typewriter” product called ‘Freewrite’.

Launch Website
Full Review


Giovanni Xu (Portfolio)

Slick transitions in this arty One Pager for French interaction designer, Giovanni Xu. The Single Page website features lovely big scattered imagery that fills a big screen well along with projects that load smoothly with AJAX. A pity there is no mobile adaption for the portfolio section but a solid One Pager no doubt.

Launch Website
Full Review


24 Lever Street (Accommodation)

What a gorgeous colorful One Pager filled with fun character animations representing ’24 Lever Street’. The long scrolling Single Page website features a tall illustrated building showcasing which tenants occupy each floor of ’24 Lever Street’ along with the vacancies. Lovely collaborative work this by Nine Sixty & True North digital agencies from UK.

Launch Website
Full Review


Facebook Newsfeed (Landing Page)

Gorgeous transitions and animations in this brilliant One Pager by Facebook demonstrating how to customise your Facebook newsfeed. It’s definitely a “Most Loved” award but disappointing to see how some love was lost with the typography towards the end. Another standout is the inconsistency between “Newsfeed” and “News Feed” in the site copy vs Meta tags? That being said the interactions are phenomenal and a solid reference to showcasing features on any product. Interesting (and awesome) to see how this is a WordPress site hosted on WordPress VIP!

Launch Website
Full Review


Adam Woodhouse (Personal, Portfolio)

Gorgeous One Page redesign with rich imagery for Toronto-based Creative Director, Adam Woodhouse. Lovely little touches with the moving universe (especially in the astronaut helmet reflection) background and those bright glowing rocket exhaust flames.

Launch Website
Full Review


Bryant Hughes (__CAT____)

Gorgeous spacing design in this personal One Pager for Chicago-based web developer, Bryant Hughes. The Single Page website features a lovely load transition and slick diagonal section dividers that subtly reveal background mountain peaks. Neat touch with the flying birds over the mid section mountain peak. Reminds me a lot of the We Ain’t Plastic One Pager.

Launch Website
Full Review


Hope you enjoyed these epic 8 from March!


by Rob Hope via One Page Love