Skip to content

Instantly share code, notes, and snippets.

View premrajah's full-sized avatar

Prem R premrajah

  • London
View GitHub Profile
@premrajah
premrajah / gist:3a24c7484c1d1f89cc936d05269d8cf6
Created November 11, 2024 10:21
Delayed setTimeout for testing JS
// REMOVE
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const test = async () => {
await sleep(500);
}
@premrajah
premrajah / highlightTextHelper.jsx
Created October 23, 2024 14:42
React highlight text with Index
import React from "react";
export const highlightTextHelper = (input, searchTerm) => {
if (!input || !searchTerm) return <>{input}</>;
let textIndex = input.toLowerCase().indexOf(searchTerm.toLowerCase());
if (textIndex !== -1) {
let startText = input.substring(0, textIndex);
let foundText = input.substring(textIndex, textIndex + searchTerm.length);
@premrajah
premrajah / SQL Empty Data Set
Last active May 11, 2020 22:19
Simple SQL Hack - Use SQL to get a empty data Set to view all the column names
SELECT * FROM table_name
WHERE 1 = 2;
function ValidAnagram(first, second) {
if(first.length !== second.length){
return false;
}
const lookup = {};
for(let i = 0; i < first.length; i++){
let letter = first[i];
// if letter exists, increment or set to 1
@premrajah
premrajah / Bootstrap4_Button_Generator
Last active August 2, 2019 21:11
Bootstrap 4 CSS Button Generator
npm install bootstrap
Use sass compiler to compile to css
@import './node_modules/bootstrap/scss/bootstrap.scss';
$mynewcolor:rgb(7, 173, 136);
.btn-primary {
@include button-variant($mynewcolor, darken($mynewcolor, 7.5%), darken($mynewcolor, 10%), lighten($mynewcolor,5%), lighten($mynewcolor, 10%), darken($mynewcolor,30%));
}