Skip to content

Instantly share code, notes, and snippets.

View vinnymac's full-sized avatar
🤓

Vincent Taverna vinnymac

🤓
View GitHub Profile
@vinnymac
vinnymac / useEventListener.js
Created October 29, 2018 16:44
Use an event listener on a specific element with React Hooks
import { useEffect, useRef } from "react";
export default function useEventListener(event, callback) {
const element = useRef(null);
useEffect(() => {
element.current.addEventListener(event, callback);
return () => element.current.removeEventListener(event, callback);
}, []);
@vinnymac
vinnymac / config.plist
Created February 5, 2019 15:03
10.14 Hackintosh Z390i, i9-9900K, and Vega 64 Configuration File
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Boot</key>
<dict>
<key>Arguments</key>
<string>keepsyms=1 dart=0 -wegbeta -lilubetaall -vsmcbeta -alcbeta</string>
<key>DefaultVolume</key>
<string>LastBootedVolume</string>
@vinnymac
vinnymac / README.md
Last active October 13, 2020 00:25
Guide to Hackintosh (specifically for Z390i/9900K/Vega64 build)
@vinnymac
vinnymac / sniff-linux.sh
Last active February 12, 2019 17:04
Sniff machine names from a local or remotely connected network without additional installs
#!/bin/bash
for a in $(arp -n | tail -n+2 | cut -d' ' -f1);
do
nmblookup -A $a;
done
@vinnymac
vinnymac / bfs.js
Created September 11, 2019 16:00
Tree Traversal DFS vs BFS JavaScript
class BFSTree extends Tree {
traverse(callback) {
const queue = [this.graph];
let node
while (queue.length > 0) {
node = queue.shift();
callback(node.value);
@vinnymac
vinnymac / README.md
Last active July 28, 2022 23:31
Amazon Interview Islands Question (Daily Coding Problem)

Good morning! Here's your coding interview problem for today.

This problem was asked by Amazon.

Given a matrix of 1s and 0s, return the number of "islands" in the matrix. A 1 represents land and 0 represents water, so an island is a group of 1s that are neighboring whose perimeter is surrounded by water.

For example, this matrix has 4 islands.

1 0 0 0 0
@vinnymac
vinnymac / README.md
Last active September 16, 2019 15:42
Daily Coding Problem: Problem #85 [Medium]

Good morning! Here's your coding interview problem for today.

This problem was asked by Facebook.

Given three 32-bit integers x, y, and b, return x if b is 1 and y if b is 0, using only mathematical or bit operations. You can assume b can only be 1 or 0.

@vinnymac
vinnymac / README.md
Created September 16, 2019 20:39
Daily Coding Problem #1

Problem 1

Given a list of numbers, return whether any two sums to k. For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.

Bonus: Can you do this in one pass?

@vinnymac
vinnymac / README.md
Created September 16, 2019 21:13
Daily Coding Problem #2

Problem 2

This problem was asked by Uber.

Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.

For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6].

Follow-up: what if you can't use division?

% IANA WHOIS server
% for more information on IANA, visit http://www.iana.org
% This query returned 1 object
refer: whois.verisign-grs.com
domain: COM
organisation: VeriSign Global Registry Services
address: 12061 Bluemont Way