Skip to content

Instantly share code, notes, and snippets.

View kingisaac95's full-sized avatar

Kingdom Orjiewuru kingisaac95

View GitHub Profile
const validateEmail = (email) => {
if (!email) return false;
return /^[\w\-.]+@([\w-]+\.)+[\w-]{2,}$/.test(email);
};
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') {
function draggableElement({ elementId }) {
const element = document.getElementById(elementId);
const positions = {
pos1: 0,
pos2: 0,
pos3: 0,
pos4: 0,
};
element.onmousedown = mouseDown;
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' },
@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?
@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 / searchContact.js
Last active August 5, 2021 13:54
A simple algorithm to search through a contact list; where contact list is an array with first and last names spaced out.
const sampleData = ['tom harry', 'dike harry', 'girl guy', 'boo baa'];
/**
* use first/last name to create regex pattern
* if no last name return first name pattern
*/
const getSearchPattern = (terms, index) =>
new RegExp(".*" + (terms[index] ? terms[index] : terms[0]) + ".*");
const searchUsers = (searchTerm) => {
@kingisaac95
kingisaac95 / readFile.js
Last active November 18, 2021 16:41
File Reader to Base64
/*
* @params - event: upload file event
* @params - onComplete: callback provided by caller
*/
const uploadFile = ({ event, onComplete }) => {
event.preventDefault();
var base64File = null;
const file = event.target.files[0];
class DynamicForm extends React.Component {
constructor(props) {
super(props);
this.state = {
education: [
{ name: '', start: '', end: '' },
]
}
}
import React, { Component } from 'react';
import { Link } from 'react-router';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import Name from './Name.jsx';
import { fetchUserData } from '../../../actions/getUserActions';
class WorkShop extends Component {
constructor(props) {
super(props);