How to get Form data in React

With event elements import React from ‘react’; class ReactForm extends React.Component { handleSubmit(event) { event.preventDefault(); console.log([0].value); console.log([1].value); } render() { return( <form onSubmit={this.handleSubmit}> <label>name</label> <input /> <label>email</label> <input /> <button type=”submit”>Submit</button> </form> ) } } With event named elements import React from ‘react’; class ReactForm extends React.Component { handleSubmit(event) { event.preventDefault(); cosnole.log(; cosnole.log(; } render() […]

Sorting Algorithms Quick Rundown

Bubble Sort Runtime: O(n^2) Memory: O(1) Start at the beginning Swap the first 2 elements if the first > second Repeat until the list is sorted const bubbleSort = array => { for (i = 0; i < array.length; i++) { for (j = 1; j < array.length; j++) { if (array[j – 1] > […]

Essential Data Structures

Array & String Hashtables Compute key’s hash code -> Int/long keys can share the same hash Find index of the array hash % array_length Use linkedlist to store key and value at this index ArrayList & Resizable Arrays Resizing ArrayList takes O(1) Doubling takes O(n) but very rare so its amortized insertion time is still […]

Blue / Green Deployment

What is Blue / Green Deployment? Blue / Green deployment is a technique companies use to release new versions of their application with no downtime. This technique involves two identical environments running on a single or multiple servers. We will call these Blue and Green environments. On a high level, just imagine that there is […]

Nginx configuration cheatsheet

Nginx Cheatsheet Nginx vs Apache Nginx interprets incoming requests as URI locations whereas Apache prefers to interpret requests as filesystem locations Nginx can handle more concurrent processes Nginx requires less resources Nginx.conf Overall worker_process sets the number of CPU cores to produce the best performance “auto” sets to the number of CPU cores available use […]

Getting started with Docker on Ubuntu

Docker is a technology that allows you to run many types of applications in containers. For those of you who are not familiar with the concept of containers, I like to think of them as super lightweight VMs that do not require its own operating systems. Here’s a diagram that I made to help you […]

Redirect HTTP to HTTPS on Nginx

This post assumes that you have your app running and are using Nginx as the reverse proxy for your web app/server. Technologies Nginx Usage Separate Servers server { listen 80; server_name; return 301 https://[server_name][request_uri]; } server { listen 443 ssl; server_name; … } Concatenated Servers server { listen 80; listen 443 ssl; …. […]

How to use promises in nodejs

This post is going to be about writing promises in nodejs. In many projects that utilize a database server, it’s common that the application needs to wait for the data to be fetched before performing any operations on it. Therefore we need to implement an asynchronous function using promises. Technologies Node – v6.11.5 Usage Promise […]

React Nodejs Webpack Boilerplate Project

React is one of the hottest frontend libraries today. Its component based structure makes projects easy to manage. Although it is popular and powerful, it’s still only the view of the MVC framework. Personally I enjoy using Nodejs and Express for backend development. In the past 2 years, I have started many personal and work […]