Posts

  • Typescript Getter and Setter Mar 07 2018
    This is something that you probably don’t ever think about, but getters and setters are implicit on every javascript object. For example, if we take the following: person = {}; person.name = 'Dave' //uses the implicit setter on the object console.log(person.name) //uses the implicit getter The above code is something that you have probably have seen very often in javascript. However, this doesn’t give you much control over how properties are accessed or defined.

  • Angular 4 input only numbers Directive Mar 07 2018
    I was working on a project in Angular 4 and needed to implement input fields that only accept numerical values. My first thought was to simply add the HTML5 type=”number” to the input. Unfortunately, this isn’t supported in Internet Explorer 10 and some of the clients would most likely be using Internet Explorer 10. My only other option was to implement a directive. Thanks to this StackOverflow answer, I was able to modify it to my needs.

  • Implementing Token Interceptor and Retry in Angular 4 Feb 23 2018
    If you are building a web application using Angular 4 or Angular 5 there’s a good chance that you might be working with JWT tokens. Luckily, implementing token interceptor and retry in Angular 4 and beyond is very easy thanks to the new HTTP Interceptors. Using this, we can add an authorization header to every outbound request while also implementing a retry mechanism for requests that fail due to an expired token.

  • Implementing Token Interceptor and Retry in Angular 4 Feb 23 2018
    If you are building a web application using Angular 4 or Angular 5 there’s a good chance that you might be working with JWT tokens. Luckily, implementing token interceptor and retry in Angular 4 and beyond is very easy thanks to the new HTTP Interceptors. Using this, we can add an authorization header to every outbound request while also implementing a retry mechanism for requests that fail due to an expired token.

  • Simple CSS Hack Can Steal Internet Passwords Feb 21 2018
    A user on GitHub just posted an alarming exploit shows how a simple CSS hack can steal internet passwords. It’s kinda funny how you wouldn’t really think of CSS when it comes to vulnerabilities and hacking. Since CSS is only used to style a webpage, its threat level is generally considered to be relatively low. However, CSS does provide developers with very advanced selectors. In this case, if you wanted to select an input with the value of A in it and turn it red, then CSS allows you to do that.

  • How to build a forum Feb 20 2018
    Practically every online community has a forum. It makes sense though because forums are a great way to facilitate online discussion. Now let’s say that you wanted to build your own online forum. Well, building a very basic forum wouldn’t be too complicated. Just script together some PHP with an MYSQL database and you will be all set. Unfortunately, this would likely leave you vulnerable to many potential security holes and a terrible user experience.

  • Angular 4 Forms Jan 13 2018
    One of my favorite features in Angular are forms. Using Angular 4 forms or Angular 5 forms are very helpful because they provide for quick validation and object mapping. Here’s how you can create a basic angular 4 form (also works with angular 2, and angular 5). HTML You will also notice that I am using Bootstrap for some styling, that is completely optional. Let’s look at the form HTML:

  • Android Recyclerview for Installed Apps with Checkbox Jan 13 2018
    One of the most common reasons that you would want to use the android recyclerview is if you want to show a list of some sort. In this example, let’s take a look at how you can use the android recyclerview to show a list of installed apps on your device. Within each item, we will also include a checkbox. Here’s what it will look like: Layout Let’s first take care of creating the layout files.

  • Use Machine Learning to Predict the Value of Bitcoin Jan 08 2018
    The day has finally come at which I can use machine learning and bitcoin in the same article. The only thing that would impress me more would be relating the topics of machine learning, bitcoin, and blockchain in the same article, but I digress. Anway, the value of bitcoin is astonishing. It went from $900 to well over $14,000 in less than 6 months time! So hey, let’s start riding this bubble and try to cash in before its too late.

  • Meltdown and Spectre – Possible Javascript Vulnerabilities Jan 05 2018
    This has been a very interesting New Year. So far, 2018 has brought us two of the biggest bugs to hit CPUs in the past 12 years: Meltdown and Spectre. Intel is struggling to get their Meltdown bug under control while Amazon and Microsoft brutally await its impact on their cloud services. Both Meltdown and Spectre are serious issues, but Meltdown is easier to exploit and gives attackers more valuable information.

  • Best Chrome Extensions for Web Development Dec 28 2017
    Google Chrome and its developer tools are an absolute necessity for any web developer. But you shouldn’t stop there because there are even more great tools and extensions that will help you with web development and design. So let’s take a look at some of the best Chrome extensions for web development. React Developer Tools If you plan on doing development in React, then you should definitely download this extension. It makes debugging a lot easier because you can see your whole app’s hierarchy and look at the values for each state and prop from all of your components.

  • Bootstrap Navbar Collapse in ReactJS Dec 27 2017
    Bootstrap is an amazing library and works wonders with ReactJS. Unfortunately, you can’t (or really shouldn’t) use Bootstrap.js with React because bootstrap directly manipulates the DOM; which could break React’s nice rendering flow. This becomes a big problem if you wanted to implement a Navbar using plain bootstrap. Take the following for example from Bootstrap’s documentation: You could directly take this code and put it in ReactJS (but change class _to _className) and you will have a working Navbar.

  • 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++.