Category: Uncategorized

  • PHP CheatSheet

    Enable Error Display in PHP PDO CheatSheet This section includes cheatsheet of PDO. PHP PDO execute() returning duplicate results This can be solved by using FETCH_ASSOC with both fetch() or fetchAll() function. Note that you might need to use \PDO depending upon namespacing in your project, especially if it gives fatal error. PDO::FETCH_ASSOC not working […]

  • PHP OOP Concepts CheatSheet

    What is a class property A class property is just like a variable, but declared inside a class (at base level, not inside a function / method). For example: What is a class method Method is simply a function inside a class. For example: PHP OOP Encapsulation Encapsulation simply means making the data private and […]

  • CSS CheatSheet

    How to remove outline around focused input box or textarea CSS animation CSS animation fade in an element CSS animations don’t work on display property, so we can’t use keyframes to make an element display: none to display: block or anything else. Instead, we can use opacity. Example code would look like this: CSS transitions

  • JavaScript Cheatsheet

    ForEach loop in javascript: Export & Import modules in JavaScript ES6 (node / react / nextjs) We can export multiple items from a single file in javascript ES6 module. Check following examples, all can happen in one file. Note that we also have one default export, also one “as” export (see below on how to […]

  • Discordjs Cheatsheet

    HelloWorld discordjs bot The very basic hello world bot can be coded by copying this: This bot will respond with pong when the user messages ping in the channel. Make sure that you add the token from discord developers section for this bot. Check if bot can assign a role to users This needs 2 […]

  • Deploy full stack React app on AWS EC2 (or any vps)

    In this tutorial we will configure a vps server using aws ec2 instance to run nodejs app along with nginx as a reverse proxy. Don’t get confused, it sounds complex but it’s just a straight forward process. AWS EC2 vs Amazon Amplify or Heroku to host full stack react app Note that this is also […]

  • Setup Nginx on Virtual Server & deploy React app, Server & Client

    In this tutorial we will configure the nginx on a virtual server (aws EC2 in our case, but can be any virtual server from any other provider like digital ocean, google cloud console, etc.). Static / Persistent / Elastic IP If you’re on amazon aws then you need to setup elastic ip for this ec2 […]

  • How to open ports for aws EC2 instance

    When we crreate new aws ec2 instances, they only have port 22 opened by default due to default security policy. If we want to use this instance as a webserver for our websites or for nodejs apps or node servers running behind react app, etc., we need to open relevant ports on the aws ec2 […]

  • How to create AWS EC2 instance & login using .pem

    This tutorial explains how you can create a cloud virtual server on amazon, called aws EC2 instance. We will create a free tier instance running latest ubuntu and login to it using the .pem file provided by amazon. This post contains: How to create an AWS EC2 instance How to connect to aws EC2 instance […]

  • How to reset nginx on server

    Nginx configuration can be confusing sometimes. You could simply mess up your whole server while playing around with it and following steps on every random tutorial that you encounter online. In that situation, instead of trying to fix the bug that you created yourself, it’s sometimes useful to just start fresh and reset the nginx […]