Skip to content

Instantly share code, notes, and snippets.

View kingisaac95's full-sized avatar

Kingdom Orjiewuru kingisaac95

View GitHub Profile
@kingisaac95
kingisaac95 / find_and_kill_process_on_port
Created March 6, 2019 13:59
Find and kill process on port.
lsof -i TCP:<port>
kill -9 <port PID>
@kingisaac95
kingisaac95 / structure_of_an_interview.txt
Created July 29, 2019 14:54
Structure of an interview
General - Structure of an interview (soft-skills)
1. Ask if we can record the interview
2. Explain interview process in terms of duration and structure (Introduction then we ask questions then he ask questions)
3. Introduction of the interviewer/company/tech team
4. Which one do you prefer and why: teamwork or working alone?
5. Do you like the responsibility of decision-making or would you prefer to leave it to someone else?
const sampleOptions = [
{ id: 'option-type', value: '3' },
{ id: 'option-type', value: '100336' },
{ id: 'option-type', value: '100354' },
{ id: 'option-type', value: '3' },
{ id: 'option-type', value: '109538' },
{ id: 'option-type', value: '3' },
{ id: 'option-type', value: '8303' },
{ id: 'option-type', value: '504' },
{ id: 'option-type', value: '503' },
function draggableElement({ elementId }) {
const element = document.getElementById(elementId);
const positions = {
pos1: 0,
pos2: 0,
pos3: 0,
pos4: 0,
};
element.onmousedown = mouseDown;
import { useEffect, useRef, useState } from 'react';
function useComponentVisible(initialIsVisible) {
const [isComponentVisible, setIsComponentVisible] = useState(
initialIsVisible
);
const ref = useRef(null);
const handleHideDropdown = (event) => {
if (event.key === 'Escape') {
const validateEmail = (email) => {
if (!email) return false;
return /^[\w\-.]+@([\w-]+\.)+[\w-]{2,}$/.test(email);
};
@kingisaac95
kingisaac95 / Tabs.jsx
Created June 30, 2021 16:44
Tabs Component - React
// Tabs.jsx
import PropTypes from 'prop-types';
import { useState } from 'react';
import styles from './Tabs.module.css';
export const Tabs = ({ tabHeaders, children, defaultTab }) => {
const [currentTab, setCurrentTab] = useState(defaultTab.toLowerCase());
const handleTabSelect = (tabHeader) => {
setCurrentTab(tabHeader.toLowerCase());
const uploadFile = ({
event,
onComplete
}: {
event: ChangeEvent<HTMLInputElement>;
onComplete: (file: File, base64File: string) => void;
}) => {
event.preventDefault();
let base64File: string;
@kingisaac95
kingisaac95 / formatCount.js
Created November 29, 2021 13:16
Add comma separation in numbers
const formatCount = (x) => x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
@kingisaac95
kingisaac95 / retry.js
Created December 10, 2021 10:46
Retry promise
function retry(fn, retries = 2, err = null) {
console.log("Retries: ", retries);
if (!retries) {
console.log("Done Retrying...");
return Promise.reject(err);
}
return fn().catch((err) => {
console.log("Retrying...");
return retry(fn, retries - 1, err.response);