Web Development
-
PHP Query SQL Database return JSON
Dec 27 2017
As a Javascript developer, I always prefer to use NodeJS as my API endpoint when interacting with a backend database. Unfortunately, it’s not always feasible to use NodeJS (especially in a shared hosting environment) and you might have to fall back to good old PHP. So here’s a quick refresher on how you can perform queries to a SQL database using PHP from an Ajax or Fetch call. Fetch Call Suppose I have the following XMLhttp request using the fetch API:
-
PHP insert into SQL database from Fetch POST
Dec 27 2017
As a Javascript developer, I always prefer to use NodeJS as my API endpoint when interacting with a backend database. Unfortunately, it’s not always feasible to use NodeJS (especially in a shared hosting environment) and you might have to fall back to good old PHP. So here’s a quick refresher on how you can insert an object into an SQL database from javascript using php. If you haven’t already, check out my previous tutorial on making SQL queries from PHP using fetch API.
-
GPU Programming in Javascript
Dec 26 2017
You probably don’t think about Javascript when you hear the words GPU programming. However, it should come as no surprise that there is a library to do anything and that includes GPU Programming in Javascript. Let’s get one thing clear though, you should probably not do this if you are looking to do serious GPU programming. For serious GPU programming, I recommended that you work with Nvidia’s CUDA in C and C++.
-
Javascript for of vs for in vs for each
Dec 22 2017
If you are new to Javascript (or even a seasoned js developer), you will probably get confused when trying to understand the different types of for loops. So let’s go through the javascript for of vs for in vs for each loop. Standard for loop Suppose we have an array called myArray. Here’s how you would iterate through it using the standard for loop: var myArray = ['Cat','Dog','Horse']; for(let i =0; i< myArray.
-
Subscribe to variable change in Angular 4 Service
Dec 22 2017
If you want to subscribe to variable change in Angular 4 service or Angular 5 service, you can use something called the BehaviorSubject from the rxjs library. A behavior subject is like an observable, except that it must be created with an initial value as it is must always return a value even if the subject hasn’t been updated. A behavior subject will always emit it’s first value as soon as it’s described.
-
Build a Multiplayer game using Javascript
Dec 10 2017
In this tutorial, we will take a look at how to build a multiplayer game using Javascript and NodeJS. My goal is to take you through the basic setup so that you can begin focusing on the actual gameplay. When building a full-scale MMO, there are a lot of things to consider like load balancing, network contingencies, etc. For now, we are going to focus on the bare minimum just to help you get an understanding of how you can creatively and effectively use the available tools of NodeJS to get started.
-
Navigate in ReactJS using React V4 Router
Nov 23 2017
If you are building a large single page application, there might come a time when you will need to add routes to different pages. Unlike traditional routes, adding routes in ReactJS does not trigger a page reload. This makes your SPA extremely fast and feels more like an actual application rather than a simple website. To navigate in ReactJS we will be using the React v4 router.
Setting Up React V4 Router
Begin by installing the React V4 Router from npm:
-
Understanding the JavaScript Spread Operator
Nov 23 2017
There’s a good chance that you have probably come across the Javascript spread operator. If you are unsure, here’s what it looks like: {...} Good luck trying to google search that as you will probably get an empty results page. The Javascript spread operator is a new syntax found in ES6 (ECMAScript2015). The purpose of the spread operator is to allow an iterable like an array or string to be expanded (or spread) across another object or array.
-
Multithreaded Javascript
Oct 22 2017
For the longest time, Javascript has always been implemented using a single thread in your browser. For the most part, this wasn’t a problem. If you’re just using javascript for simple DOM manipulations or form submissions then a single thread is all you need. However, once developers started getting more advanced with their Javascript usage, this eventually led to an issue. Let’s say I have the following single page application (SPA) that shows a list of prime numbers from 1 to 600,000:
-
JavaScript Read USB
Oct 15 2017
You can now officially use JavaScript to read USB devices that are connected to your computer. This is using the new WebUSB API that is still in early draft. As being so, the API could later change or be removed altogether until it receives the final verification. In order to use WebUSB you need to be running the latest version of Google Chrome, with the experimental web platform features flag enabled.
-
Reddit API Application only OAuth in Javascript
Oct 15 2017
Before you begin developing your Reddit application, you will need to make sure that your app is authorized to access the Reddit API. Authorization is done through OAuth tokens that you receive from the Reddit server. The flow is pretty straightforward: Application Requests Token App Receives Token that’s valid for an hour App makes API calls with given token App request new token when the previous token expires For this tutorial, we are going to build a simple app that grabs the new posts from a subreddit.
-
JavaScript Callbacks
Aug 17 2017
In Javascript, a callback function is a function that is passed into another function as an argument. This allows you to invoke that function with a return value. Remember, Javascript’s implementation within a browser is single threaded (well..until recently at least). That means that all of your code is executed within one linear operation. However, there are some functions in Javascript which are asynchronous. That means that they have the privilege to be invoked anywhere in that line of execution.