This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Git branch in prompt. | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
export PS1="\e[2m\u@\h\e[22m \W/\[\033[32m\]\$(parse_git_branch)\[\033[00m\]: " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import asyncio | |
import websockets | |
import json | |
import time | |
import board | |
import neopixel | |
pixel_pin = board.D18 | |
num_pixels = 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node { | |
constructor (val) { | |
this.value = val; | |
this.children = []; | |
} | |
} | |
function depthFirstSearch(seek, node) { | |
if (seek === node.value) return node; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node { | |
constructor (val) { | |
this.value = val; | |
this.children = []; | |
} | |
} | |
function breadthFirstSearch (seek,node) { | |
if (seek === node.value) return node; | |
const queue = [node]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function binarySearch (search, arr) { | |
let lower = 0; | |
let upper = arr.length; | |
while (lower < upper) { | |
let mid = lower + Math.floor((upper - lower) / 2); | |
if (arr[mid] === search) { | |
return mid; | |
} else if (arr[mid] < search) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function quickSort(arr) { | |
if (arr.length <= 1) return arr; | |
const pivot = arr[Math.floor(arr.length/2)]; | |
const lower = arr.filter(val => val < pivot); | |
const equal = arr.filter(val => val === pivot); | |
const higher = arr.filter(val => val > pivot); | |
return [...quickSort(lower), ...quickSort(equal), ...quickSort(higher)]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function binarySearch (search, arr) { | |
let lower = 0; | |
let upper = arr.length; | |
while (lower < upper) { | |
let mid = lower + Math.floor((upper - lower) / 2); | |
if (arr[mid] === search) { | |
return mid; | |
} else if (arr[mid] < search) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function quickSort(arr) { | |
if (arr.length <= 1) return arr; | |
const pivot = arr[Math.floor(arr.length/2)]; | |
const lower = arr.filter(val => val < pivot); | |
const equal = arr.filter(val => val === pivot); | |
const higher = arr.filter(val => val > pivot); | |
return [...quickSort(lower), ...quickSort(equal), ...quickSort(higher)]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function biggestPalindrome (str) { | |
if (str.length === 1) return str; | |
const pieces = str.split(''); | |
let longestPalindrome = ''; | |
for (let i = 1; i <= pieces.length; i++) { | |
let offset = 1; | |
do { | |
if (pieces[i-offset] === pieces[i+offset]) { | |
const newPalindrome = str.substring(i-offset, i+offset+1); | |
if (newPalindrome.length > longestPalindrome.length) longestPalindrome = newPalindrome; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node { | |
constructor (val) { | |
this.value = val; | |
this.left = null; | |
this.right = null; | |
} | |
add (val) { | |
if (val === this.value) return; |
NewerOlder