Skip to content

Instantly share code, notes, and snippets.

View SahanKumarasiri's full-sized avatar
🎯
Focusing

Sahan Kumarasiri SahanKumarasiri

🎯
Focusing
View GitHub Profile
# Install and start nginx
sudo amazon-linux-extras install nginx1
sudo service nginx status
sudo service nginx start
# Install dependencies
sudo yum install augeas-libs
# Set up a Python virtual environment
sudo python3 -m venv /opt/certbot/
import React, { useEffect, useState, useRef } from "react";
import { useDispatch, useSelector } from "react-redux";
import { CommonTable } from "../../../../../components/common/table/Table";
import { SearchOutlined } from "@ant-design/icons";
import { Switch, Form, Menu, Checkbox, Tooltip } from "antd";
import { InputField } from "../../../../../components/common/fields/inputField/InputField";
import { push } from "connected-react-router";
import { searchIcon } from "../../../../../constant/Images";
import { Button } from "../../../../../components/common/button/Button";
import { proposalStatusMap } from "./proposalStatusMap";
import React, { useState, useEffect } from "react";
import "antd/dist/antd.css";
import { Form, Input, Button, Spin, Tooltip, notification } from "antd";
import TextArea from "antd/lib/input/TextArea";
import {
BranchesOutlined,
DeleteOutlined,
DesktopOutlined,
FileDoneOutlined,
InfoCircleOutlined,
<html>
<head>
<title>Amaya</title>
</head>
<body>
<script>
let value = 1;
function getValue() {
return new Promise((resolve, reject) => {
setTimeout(() => {
<html>
<head>
<title>Amaya</title>
</head>
<body>
<script>
let value = 1;
function getValue() {
return new Promise((resolve, reject) => { //return new Promise
setTimeout(() => {
@SahanKumarasiri
SahanKumarasiri / App.js
Created February 19, 2022 04:47
react-router-dom v6
import "./App.css";
import React, { useEffect, useState } from "react";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import Home from "./components/Home";
import AddRecipe from "./components/AddRecipe";
import NavBar from "./components/NavBar";
import Footer from "./components/Footer";
import UpdateRecipe from "./components/UpdateRecipe";
import ViewRecipe from "./components/ViewRecipe";
@SahanKumarasiri
SahanKumarasiri / promises.html
Created February 16, 2022 13:00
Callbacks and Promises
<html>
<head>
<script>
async function fetchData(){
await fetch("https://jsonplaceholder.typicode.com/users") //browser inbuilt API for requests
.then(res => res.json()) //do the first promise : convert res to JSON format
.then(json => console.log(json)) //do the second promise
.catch(error => console.log(error)); //if promise broke catch the error
};
<html>
<head>
<script>
function Calculator(taxPercentage){ //closure
return function calcTotal(amount){ //return a new function
return amount + (amount * taxPercentage);
}
}
@SahanKumarasiri
SahanKumarasiri / Amaya.html
Created February 16, 2022 10:59
this keyword
<html>
<head>
<script>
window.name = "Amaya"; //define a window object
var user = "Srimani"; //var is used define global object
function Person(){
this.name = "Sahan";
}
@SahanKumarasiri
SahanKumarasiri / a.html
Last active March 29, 2022 11:30
Prototype and Inheritance
<html>
<head>
<script>
function Person(){
this.name = "Amaya";
}
Person.prototype.getName = function(){ // set the getName method to Person prototype
return this.name;