[ This is a content summary only. Visit our website http://bit.ly/1b4YgHQ for full links, other content, and more! ]
by Saima Salim via Digital Information World
"Mr Branding" is a blog based on RSS for everything related to website branding and website design, it collects its posts from many sites in order to facilitate the updating to the latest technology.
To suggest any source, please contact me: Taha.baba@consultant.com
Emerging technology has reached new heights as we enter 2019. Virtual and augmented reality, machine learning, robotics, the Internet of Things... there's so much potential out there right now. The great news is that it is also getting easier and easier to learn about these areas. Rather than sit on the sidelines, why not keep up with emerging technology and get involved? Here are my tips on where and how to start learning about emerging technology in 2019.
Chances are high that if you're a SitePoint reader you already have a bit of knowledge about coding. The most important takeaway from this article is this — you can use your existing coding skills as a starting point. Everything from HTML and JavaScript to Python can be used to get started with an emerging tech project. You don't even need to be crazy advanced! Even basic JavaScript knowledge can be enough to make it easier to jump into emerging tech.
Here are a few examples of ways you can bring your existing knowledge into emerging tech:
The post Where to Start Learning Emerging Tech in 2019 appeared first on SitePoint.
This article was originally published on the Okta developer blog. Thank you for supporting the partners who make SitePoint possible.
During the past 10 years or so, the concept of REST APIs for web services has become the bread and butter for most web developers. Recently a new concept has emerged, GraphQL. GraphQL is a query language that was invented by Facebook and released to the public in 2015. During the last three years, it has created quite a stir. Some regard it as a new revolutionary way of creating web APIs. The main difference between traditional REST and GraphQL is the way queries are sent to the server. In REST APIs you will have a different endpoint for each type of resource and the response to the request is determined by the server. Using GraphQL you will typically have only a single endpoint, and the client can explicitly state which data should be returned. A single request in GraphQL can contain multiple queries to the underlying model.
In this tutorial, I will be showing you how to develop a simple GraphQL web application. The server will run using Node and Express and the client will be based on Angular 7. You will see how easy it is to prepare the server for responding to different queries. This removes much of the work needed compared to implementing REST-style APIs. To provide an example I will create a service in which users can browse through the ATP Tennis players and rankings.
I will start by implementing the server. I will assume that you have Node installed on your system and that the npm command is available. I will also be using SQLite to store the data. In order to create the database tables and import the data, I will be making use of the sqlite3 command line tool. If you haven’t got sqlite3 installed, head over to the SQLite download page and install the package that contains the command-line shell.
To start off, create a directory that will contain the server code. I have simply called mine server/. Inside the directory run
npm init -y
Next, you will have to initialize the project with all the packages that we will be needing for the basic server.
npm install --save express@4.16.4 cors@2.8.4 express-graphql@0.6.12 graphql@14.0.2 sqlite3@4.0.2
Next, let’s create the database tables and import some data into them. I will be making use of the freely available ATP Tennis Rankings by Jeff Sackmann. In some directory on your system clone the GitHub repository.
git clone https://github.com/JeffSackmann/tennis_atp.git
In this tutorial, I will only be using two of the files from this repository, atp_players.csv and atp_rankings_current.csv. In your server/ directory start SQLite.
sqlite3 tennis.db
This will create a file tennis.db that will contain the data and will give you a command line prompt in which you can type SQL commands. Let’s create our database tables. Paste and run the following in the SQLite3 shell.
CREATE TABLE players(
"id" INTEGER,
"first_name" TEXT,
"last_name" TEXT,
"hand" TEXT,
"birthday" INTEGER,
"country" TEXT
);
CREATE TABLE rankings(
"date" INTEGER,
"rank" INTEGER,
"player" INTEGER,
"points" INTEGER
);
SQLite allows you to quickly import CSV data into your tables. Simply run the following command in the SQLite3 shell.
.mode csv
.import {PATH_TO_TENNIS_DATA}/atp_players.csv players
.import {PATH_TO_TENNIS_DATA}/atp_rankings_current.csv rankings
In the above, replace {PATH_TO_TENNIS_DATA} with the path in which you have downloaded the tennis data repository. You have now created a database that contains all ATP ranked tennis players ever, and the rankings of all active players during the current year. You are ready to leave SQLite3.
.quit
Let’s now implement the server. Open up a new file index.js, the main entry point of your server application. Start with the Express and CORS basics.
const express = require('express');
const cors = require('cors');
const app = express().use(cors());
Now import SQLite and open up the tennis database in tennis.db.
const sqlite3 = require('sqlite3');
const db = new sqlite3.Database('tennis.db');
This creates a variable db on which you can issue SQL queries and obtain results.
Now you are ready to dive into the magic of GraphQL. Add the following code to your index.js file.
const graphqlHTTP = require('express-graphql');
const { buildSchema } = require('graphql');
const schema = buildSchema(`
type Query {
players(offset:Int = 0, limit:Int = 10): [Player]
player(id:ID!): Player
rankings(rank:Int!): [Ranking]
}
type Player {
id: ID
first_name: String
last_name: String
hand: String
birthday: Int
country: String
}
type Ranking {
date: Int
rank: Int
player: Player
points: Int
}
`);
The first two lines import graphqlHTTP and buildSchema. The function graphqlHTTP plugs into Express and is able to understand and respond to GraphQL requests. The buildSchema is used to create a GraphQL schema from a string. Let’s look at the schema definition in a little more detail.
The two types Player and Ranking reflect the contents of the database tables. These will be used as the return types to the GraphQL queries. If you look closely, you can see that the definition of Ranking contains a player field that has the Player type. At this point, the database only has an INTEGER that refers to a row in the players table. The GraphQL data structure should replace this integer with the player it refers to.
The type Query defines the queries a client is allowed to make. In this example, there are three queries. players returns an array of Player structures. The list can be restricted by an offset and a limit. This will allow paging through the table of players. The player query returns a single player by its ID. The rankings query will return an array of Ranking objects for a given player rank.
To make your life a little easier, create a utility function that issues an SQL query and returns a Promise that resolves when the query returns. This is helpful because the sqlite3 interface is based on callbacks but GraphQL works better with Promises. In index.js add the following function.
function query(sql, single) {
return new Promise((resolve, reject) => {
var callback = (err, result) => {
if (err) {
return reject(err);
}
resolve(result);
};
if (single) db.get(sql, callback);
else db.all(sql, callback);
});
}
Now it’s time to implement the database queries that power the GraphQL queries. GraphQL uses something called rootValue to define the functions corresponding to the GraphQL queries.
const root = {
players: args => {
return query(
`SELECT * FROM players LIMIT ${args.offset}, ${args.limit}`,
false
);
},
player: args => {
return query(`SELECT * FROM players WHERE id='${args.id}'`, true);
},
rankings: args => {
return query(
`SELECT r.date, r.rank, r.points,
p.id, p.first_name, p.last_name, p.hand, p.birthday, p.country
FROM players AS p
LEFT JOIN rankings AS r
ON p.id=r.player
WHERE r.rank=${args.rank}`,
false
).then(rows =>
rows.map(result => {
return {
date: result.date,
points: result.points,
rank: result.rank,
player: {
id: result.id,
first_name: result.first_name,
last_name: result.last_name,
hand: result.hand,
birthday: result.birthday,
country: result.country
}
};
})
);
}
};
The first two queries are pretty straightforward. They consist of simple SELECT statements. The result is passed straight back. The rankings query is a little more complicated because a LEFT JOIN statement is needed to combine the two database tables. Afterward, the result is cast into the correct data structure for the GraphQL query. Note in all these queries how args contains the arguments passed in from the client. You do not need to worry in any way about checking missing values, assigning defaults, or checking the correct type. This is all done for you by the GraphQL server.
All that is left to do is create a route and link the graphqlHTTP function into it.
The post Build a Simple Web App with Express, Angular, and GraphQL appeared first on SitePoint.
Creating an eCommerce store, but not sure what platform is best for you?
With so many products and solutions out there, prospects can be overwhelming. It’s tough to pick which would work best for your venture. Varying costs, system extendability, and ease of use can play huge roles in your choices. For many, however, it comes down to a choice between the two leaders: Shopify or WooCommerce.
There are quite a few other platforms out there, but few of them match the pricing and general usability of these two. That’s why WooCommerce boasts nearly 3 million installs, and Shopify powers more than 700,000 online shops.
Let’s take a look at Shopify and WooCommerce to figure out which best suits your needs.
Before we put these two eCommerce giants head to head, let's talk about how to choose an eCommerce platform. By knowing what you’re selling, how you’re selling, and how you’ll expand in the future, you’ll be able to choose the platform that’s best for you.
What should you be looking for? Here are some questions to help create your list of needs:
Once you have some rough answers to these questions, it’s time to compare Shopify and WooCommerce to your list and see how they stack up.
With your list of needs in hand, let’s take a look at our first platform: WooCommerce. One of the most commonly used eCommerce solutions on the web (if not the most common), it’s typically one of the first names that you’ll come across when building an online store.
Products for open-source platforms and popular CMSs, like WordPress for instance, sometimes fall into the trap of becoming too generic for many purposes. Let’s see what that means for WooCommerce.
WooCommerce is an eCommerce system built on top of WordPress. Because of this, it’s possible to get a basic site up on your own using only WordPress, WooCommerce, and a free website theme. Aside from hosting and a domain, there’s no cost associated with getting a minimal working online store up and running.
In addition, WordPress developers are also readily available, making it one of the most widely supported CMSs out there.
If WooCommerce doesn’t do what you need right out of the box, it’s likely that there’s a free or paid solution available. If you’re trying to spruce up your site, ThemeForest currently has over 1,000 premium themes for WooCommerce that can be easily installed. If you need something extra that falls on the side of functionality, CodeCanyon has over 1,500 plugins for WooCommerce available.
This is on top of WordPress’s already sizeable collection of plugins that cover almost every feature you could want for an eCommerce site.
Need something for your site that you can’t seem to find or apply? WordPress and WooCommerce are known for their developer friendliness. There are a plethora of great developers for the CMS that are ready and willing to help you out. You probably even have one near you!
This ability to customize and extend means that you can adjust your site to do exactly what you want, even if you’re only looking to slowly upgrade over time.
One of the downsides to using WooCommerce for your shop is that if you decide to go it alone, it can be an uphill battle. There is plenty of support available, but sometimes you need to know a little first to keep everything moving. While other eCommerce systems have been simplified to make them easier for beginners, WooCommerce and WordPress try to have finer control for developers.
However, you can set up an entire set on your own without ever working with a developer, if you’re willing to figure out how each piece works on your own. Luckily, there are plenty of guides out there for the platform that can help you get up and running.
WooCommerce excels at listing dozens or hundreds of products, and even does well with product ranges in the thousands. As you exceed these numbers, however, it becomes difficult to continue scaling without additional assistance.
This typically requires better-performing servers from web hosts, the use of Content Delivery Networks, and working with a professional developer to optimize your site. While this is par for the course with most eCommerce platforms, there are a few out there that have scalability built into their pricing model: like Shopify.
Let’s take a look at Shopify next.
Shopify is built explicitly for online stores as opposed to being an extension for a general-use website, like WooCommerce. This creates some trade-offs: typically making it more difficult to add extra eCommerce-adjacent functionality, but easier when it comes to managing a store.
Here are some of the highlights of working with Shopify.
With WooCommerce, it’s possible to get a site up for almost no cost. If you wanted your site to be custom instead of built on a free theme, you might have a one-time cost with occasional maintenance as needed—but Shopify uses a different model entirely.
The crux of the Shopify pricing model is a monthly subscription ranging from $29 to $299/month. With that ongoing cost comes a number of benefits, however. These range from discounts on shipping and regular updates to the inclusion of Shopify’s own Content Delivery Network and in-store POS solution.
Since you don’t need to manage your own hosting with Shopify, it’s possible to increase the number of products in your store as necessary, without running into limitations. If you experience a massive amount of traffic or need to add more staff to the management area of your store, you can simply upgrade your account, and Shopify handles it for you.
This means that you can spend more time on your business, and you don't need to worry about the technical infrastructure underneath.
There are significantly fewer resources out there for Shopify than WooCommerce. But that isn’t to say there aren’t any at all—on the contrary, guides, themes, and apps are available for almost any need. But the diversity is slimmer overall.
With a smaller user base and a more niche product than the WooCommerce and WordPress combo, there is a slight lack of variety. While there are thousands (if not tens of thousands) of WordPress themes out there, Shopify has roughly a tenth of that.
The same goes for apps (the Shopify version of plugins). Using SEO services as an example, when working with WooCommerce and WordPress, you may have a few dozen SEO plugins available. With Shopify, there are only a few to choose from.
When it comes to deciding between Shopify and WooCommerce, the answer lies in that needs list that we put together back at the beginning. Which platform checked off the most needs?
If you’re looking to experiment, have in-depth control, or have a small budget, then WooCommerce is likely the way to go.
If you’re looking for ease of use, reliable scaling, or tying an eCommerce shop to a brick and mortar store, Shopify might be a better pick for you.
Unfortunately, there isn’t a clear-cut choice, so finding out what your business needs are first is the best way to determine which to go with.
WooCommerce and Shopify are two of the most popular online store platforms, but there are many more! What platform do you use, and why do you like it? Let us know in the comments below!