Skip to content

Instantly share code, notes, and snippets.

View Akash52's full-sized avatar
🐢
Focusing

Akash Chauhan Akash52

🐢
Focusing
View GitHub Profile
interface Data {
id: number;
name: string;
}
// Abstraction layer representing a database
interface Database {
save(data: Data): void;
update(data: Data): void;
}
// Interface segregation for user actions
interface UserActions {
login(): void;
logout(): void;
}
// Separate interfaces for specific actions
interface EmergencyContactable {
notifyEmergencyContact(message: string): void;
}
// Abstract class representing a User
abstract class User {
// Abstract methods to be implemented by subclasses
abstract login(): void;
abstract logout(): void;
}
// Concrete subclass representing an AdminUser
class AdminUser extends User {
login(): void {
// Interface defining the behavior of content items
interface Content {
displayContent(): void;
}
// Class for displaying text content
class TextContent implements Content {
constructor(private text: string) {}
displayContent(): void {
@Akash52
Akash52 / SOP.ts
Last active March 31, 2024 21:33
// Class responsible for handling user authentication and authorization
class Authenticator {
public authenticateUser(username: string, password: string): boolean {
// Authentication logic
return true;
}
public authorizeUser(userRole: string): boolean {
// Authorization logic
return userRole === "admin";
@Akash52
Akash52 / nuxt.config.js
Created May 30, 2023 20:32
nuxt.config.js for nuxtJS
pwa: {
manifest: {
// Define basic app information
name: "Rentals Nuxt App", // Name of the app
short_name: "Rentals App", // Short name of the app
description: "Rentals App built with Nuxt.js", // Description of the app
theme_color: "#3b82f6", // Theme color of the app
lang: "en", // Language of the app
background_color: "#3b82f6", // Background color of the app
},
@Akash52
Akash52 / next.config.js
Last active May 31, 2023 18:36
next.config.js for Next.js
/** @type {import('next').NextConfig} */
const withPWA = require("next-pwa")({
dest: "public", // output directory
register: true, // register pwa
skipWaiting: true, // skip waiting for old service worker to be disabled
disable: process.env.NODE_ENV === "development", // disable in development
runtimeCaching: [
//cache assets & data from external api
{
@Akash52
Akash52 / manifest.js
Created May 28, 2023 09:50
manifest.json for all the tech
{
"name": "application name", // sets the name of the app
"short_name": "short name application", // sets a shorter name of the app
"theme_color": "#1976d2", // determines the primary color scheme used by the app
"background_color": "#fafafa", // sets the background color behind the app when it is launched
"display": "standalone", // determines how the app is displayed to users
"scope": "./", // specifies the base URL for the app and restricts its access to specific folders
"start_url": "./", // specifies the URL where the app should start when launched from the user's home screen or app launcher
"icons": [ // contains an array of objects specifying the icons used for the app
{
@Akash52
Akash52 / app.html
Created May 28, 2023 09:42
app.html for svelte
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Rentals App" />
<meta name="author" content="Rental App" />
<meta name="keywords" content="rental, app, rentals app" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
@Akash52
Akash52 / serviceworker.js
Created May 28, 2023 09:38
serviceworker.js for svelte
import { build, files } from '$service-worker';
const worker = self;
const STATIC_CACHE_NAME = 'cache-v1';
const APP_CACHE_NAME = 'offline-v1';
const CACHE_NAMES = [STATIC_CACHE_NAME, APP_CACHE_NAME];
const version = 'v1';
// hard-coded list of app routes we want to preemptively cache
const routes = ['/'];