Skip to content

Instantly share code, notes, and snippets.

@farkmarnum
farkmarnum / main.py
Last active September 5, 2023 05:27
Code to generate solutions to the prison chessboard puzzle
from collections import deque
def solve(bits: int):
# build a directed graph of node->child and also record mappings of node->parent
digraph = {}
parent_mappings = {}
for n in list(range(1 << bits)):
connections = _get_connected_numbers(n, bits)
for c in connections:
if c not in digraph or n not in digraph[c]:
@farkmarnum
farkmarnum / README.md
Last active July 13, 2022 15:35
Check Expo project for changes to packages that would necessitate a new binary

About

This script compares two branches, SOURCE_REF and TARGET_REF. It finds all packages in node_modules that contain ios or android directories, and then compares the versions of those packages between the two branches. If there are any differences, it returns with a non-zero code.

This is intended to be used within a CI process that needs to determine whether or not a new binary is needed for an Expo project.

Usage

Locally

@farkmarnum
farkmarnum / setup.sh
Created May 4, 2021 18:35
MacbookPro setup script
echo "Creating an SSH key for you..."
ssh-keygen -t rsa
# PREFS
# Show Library Folder in Finder
chflags nohidden ~/Library
# Show Hidden Files in Finder
@farkmarnum
farkmarnum / bashrc_prompt.sh
Created April 20, 2021 19:07
Abbreviate git branch and show status with color & emojis
# The various escape codes that we can use to color our prompt.
RED="\[\033[0;31m\]"
YELLOW="\[\033[1;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[1;34m\]"
ORANGE="\[\033[38;5;214m\]"
LIGHT_BLUE="\[\033[1;94m\]"
LIGHT_YELLOW="\[\033[0;93m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
@farkmarnum
farkmarnum / README.md
Last active April 9, 2021 14:15
Poll NYC Vaccine finder periodically

Vaccine appointment checker

This Python script will

  1. Check every 30 seconds for new vaccine appointments in NYC within <threshold> miles of <zipcode>.
  2. If it finds available appointments, it will open a browser window (chromedriver).
  3. Then, you can complete the signup process for the appointment.

Installation (Mac OS)

@farkmarnum
farkmarnum / intellipseOverlap.js
Created February 13, 2020 18:42
React hook for Intellipse bottom overlap
import React, { useState, useRef, useEffect } from 'react'
const getOverlap = transform => {
const overlap =
-1 * parseInt(transform.replace(/translateY\((.*)px\)/, '$1'), 10)
const intellipsePadding = 10
return Math.max(overlap - intellipsePadding, 0)
}
export const useIntellipseOverlap = () => {
@farkmarnum
farkmarnum / sec2time.js
Last active July 31, 2019 23:06 — forked from vankasteelj/sec2time.js
Javascript - Seconds to Time (hh:mm:ss,ms) -> sec2time(593.685038) becomes 00:09:53,685
function sec2time(timeInSeconds) {
var pad = function(num, size) { return ('000' + num).slice(size * -1); },
time = parseFloat(timeInSeconds).toFixed(3),
hours = Math.floor(time / 60 / 60),
minutes = Math.floor(time / 60) % 60,
seconds = Math.floor(time - minutes * 60 - hours * 60 * 60),
milliseconds = time.slice(-3);
return pad(hours, 2) + ':' + pad(minutes, 2) + ':' + pad(seconds, 2) + ',' + pad(milliseconds, 3);
}