Skip to content

Instantly share code, notes, and snippets.

View creotip's full-sized avatar

Creotip creotip

View GitHub Profile
@creotip
creotip / hasPairWithSum.js
Last active July 20, 2021 19:27
hasPairWithSum : Google coding interview solution
function hasPairWithSum(nums, sum) {
const set = new Set()
let sumArr = []
for (let i = 0; i < nums.length; i++) {
const complement = sum - nums[i]
if (set.has(complement)) {
sumArr = [[...set].indexOf(complement), i]
} else {
set.add(nums[i])
@creotip
creotip / App.js
Created July 7, 2021 15:58
React: Prevent re-rendering of a list, while removing an item
import React, { useState, useCallback } from "react";
const todos = [
{
name: "TODO Task No.0",
id: 8598554
},
{
name: "TODO Task No.1",
id: 189730
@creotip
creotip / findPeak.js
Last active August 31, 2022 07:07
Javascript: Find Peak timestamp in array of min-max timestamp values
function findPeak(arr) {
const peaks = []
let num = 0
let occur = 0
arr.forEach(item => {
for (let i = item.min; i < item.max; i++) {
peaks.push(i)
}
})
@creotip
creotip / shuffle.js
Created June 25, 2021 11:11
Javascript shuffle array
const shuffle = arr => arr.sort(() => 0.5 - Math.random())
@creotip
creotip / apps.sh
Last active November 14, 2018 09:17
Ubuntu Automatic installation of stuff for developers
sudo apt-get install -y curl
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y htop
sudo apt-get install -y vscode
sudo apt-get install -y git
sudo apt-get install -y libxss1 libappindicator1 libindicator7
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
@creotip
creotip / installApps.sh
Created November 4, 2017 11:09 — forked from anonymous/installApps.sh
Solus OS Automatic installation of stuff for developers
sudo eopkg install -y git
sudo eopkg install -y atom
sudo eopkg it gnome-tweak-tool
apm install color-picker file-icons minimap
apm install linter-csslint linter-eslint linter-js-yaml
sudo eopkg it -y neofetch
sudo eopkg bi --ignore-safety https://raw.githubusercontent.com/solus-project/3rd-party/master/network/web/browser/google-chrome-stable/pspec.xml
sudo eopkg it -y google-chrome-*.eopkg;sudo rm google-chrome-*.eopkg