Skip to content

Instantly share code, notes, and snippets.

View Kasun002's full-sized avatar
💭
{}

Kasun Abaywardana Kasun002

💭
{}
View GitHub Profile
@Kasun002
Kasun002 / docker-compose.yml
Created January 30, 2024 06:21
Configure Keycloak with PG SQL for role based authentication
version: '3.4'
volumes:
postgres_data:
driver: local
services:
postgres:
image: postgres:14.1
container_name: keycloak-nodejs-example-postgres
@Kasun002
Kasun002 / Docker
Created January 8, 2024 07:58
This is an example of deploying a React app's production build to an Nginx server. If you're deploying inside a cloud instance (such as AWS EC2), this method helps reduce the resources used on the server.
FROM node:18 AS build
WORKDIR /opt/{your app name}
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build --build-arg CACHEBUST=${CACHEBUST}
FROM nginx:latest
COPY --from=build /opt/{your app name}/build /usr/share/nginx/html
EXPOSE 81
COPY nginx.conf /etc/nginx/nginx.conf
@Kasun002
Kasun002 / dashboard.html
Created August 20, 2023 23:26
Responsive dashboard layout using tailwind css and JS. This dashboard layout contains side-bar and header mainly inside the middle container we can load any content dynamically.
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
export const fetchIssues = createAsyncThunk<string[], void, { rejectValue: string }>(
"githubIssue/fetchIssues",
async (_, thunkAPI) => {
try {
const response = await fetch("https://api.github.com/repos/github/hub/issues");
const data = await response.json();
const issues = data.map((issue: { title: string }) => issue.title);
return issues;
@Kasun002
Kasun002 / responsive_form.html
Created July 8, 2023 07:55
This form contains a responsive layout with CSS and a correct HTML structure
<!DOCTYPE html>
<html>
<head>
<!-- Page title -->
<title>Event Page</title>
<!-- Other possible tags -->
<script></script>
<style></style>
<!-- Can specify document base URL -->
@Kasun002
Kasun002 / mongoose.js
Created June 29, 2023 02:08
Express JS project Mongo-DB connection
import mongoose from 'mongoose';
const dbUri = "Your mongo DB URI" // This should be prick from .env file
export default async () => {
await mongoose.connect(dbUri,{})
.then(() => {
console.log('Mongodb Connection to database');
})
.catch(err => {