Skip to content

Instantly share code, notes, and snippets.

View JoeCortopassi's full-sized avatar

Joe Cortopassi JoeCortopassi

View GitHub Profile
# 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\]: "
import requests
import asyncio
import websockets
import json
import time
import board
import neopixel
pixel_pin = board.D18
num_pixels = 30
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)];
}
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)];
}
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;
class Node {
constructor (val) {
this.value = val;
this.left = null;
this.right = null;
}
add (val) {
if (val === this.value) return;