Skip to content

Instantly share code, notes, and snippets.

View Raja0sama's full-sized avatar
😍
CODING DAY NIGHT

Raja Osama Raja0sama

😍
CODING DAY NIGHT
View GitHub Profile
const cacheName = 'v2';
// Call Install Event
self.addEventListener('install', e => {
console.log('Service Worker: Installed');
});
// Call Activate Event
self.addEventListener('activate', e => {
console.log('Service Worker: Activated');
@echo off
:: make sure to change the settings from line 4-9
set dbUser=root
set dbPassword=""
set backupDir="F:\supersami"
set mysqldump="C:\xampp\mysql\bin\mysqldump.exe"
set mysqlDataDir="C:\xampp\mysql\data"
set zip="C:\Program Files\7-Zip\7z.exe"
import actionTypes from '../constant'
// Actions.
export const addTodo = (data) => ({ type : "S_"+actionTypes.ADD_TODO , payload : data })
export const getTodo = () => ({type : actionTypes.GET_TODO })
export const deleteTodo = (id) => ({type : actionTypes.DELETE_TODO , payload : id })
@Raja0sama
Raja0sama / Regex to Check if all Condition Exists
Created December 20, 2020 09:18
Match an Array of string from a string
MatchArrOnStrings = ({
arr: ['red', 'blue', 'green'],
string: 'We have a red and blue and green Thingies',
}) => {
const a = arr;
const b = string;
const reg = new RegExp(a.join('|'), 'g');
const c = b.match(reg);
return c.length == a.length;
@Raja0sama
Raja0sama / index.js
Created January 24, 2021 10:45
Natively enter an input value
function setNativeValue(element, value) {
const elem = document.querySelector(element);
try {
const valueSetter = Object.getOwnPropertyDescriptor(elem, "value").set;
const prototype = Object.getPrototypeOf(elem);
const prototypeValueSetter = Object.getOwnPropertyDescriptor(
prototype,
"value"
).set;
@Raja0sama
Raja0sama / index.js
Created February 12, 2021 06:06
Splash Screen
import logo from "./logo.svg";
import "./App.css";
import { useEffect, useRef, useState } from "react";
function App() {
const [state, setstate] = useState(40);
const dot1 = useRef();
const dot2 = useRef();
const dot3 = useRef();
const container = useRef();
@Raja0sama
Raja0sama / index.js
Created February 12, 2021 06:35
Splash Screen text 2
import logo from "./logo.svg";
import "./App.css";
import { useEffect, useRef, useState } from "react";
function App() {
const [state, setstate] = useState(40);
useEffect(() => {}, []);
return (
<div className="Splash">
@Raja0sama
Raja0sama / index.css
Created February 12, 2021 06:35
splash screen css 2
:root {
--color: #1c1821;
}
.Splash {
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
@Raja0sama
Raja0sama / utils.js
Created March 19, 2021 12:54
Accessing App Reference in UMI for the store.
// import
import { getDvaApp } from 'umi'
// DVA store.
const store = getDvaApp()?._store
// function, this is how you can access dispatch
export function dispatch(action) {
return getDvaApp()?._store.dispatch(action);
}
@Raja0sama
Raja0sama / server.js
Created May 1, 2021 15:28
Next Js Express Custom server
const express = require("express");
const next = require("next");
const port = process.env.PORT || 3000;
const dev = true;
const app = next({ dev });
const handle = app.getRequestHandler();
app
.prepare()