Skip to content

Instantly share code, notes, and snippets.

View adnauseum's full-sized avatar
🤘

Sam Kendrick adnauseum

🤘
View GitHub Profile
import { useEffect, useState } from 'react';
import localforage from 'localforage';
const SIX_HOURS_IN_MILLISECONDS = 21600000;
type CacheOptions = {
expireAtMilliseconds?: number;
};
type CachedItem = {
key: string;
@adnauseum
adnauseum / DiamondPrinter.kt
Last active October 3, 2019 14:55
Print Diamond of Letters: Kotlin
/*
The diamond kata takes as its input a letter, and outputs it in a diamond shape. Given a letter, it prints a diamond starting with 'A', with the supplied letter at the widest point.
Requirements
The first row contains one 'A'.
The last row contains one 'A'.
All rows, except the first and last, have exactly two identical letters.
All rows have as many trailing spaces as leading spaces. (This might be 0).
The diamond is horizontally symmetric.
@adnauseum
adnauseum / integer_palindrome.py
Created October 31, 2018 21:50
Integer Palindrome
class Solution:
def isPalindrome(self, user_supplied_integer):
"""
In order to avoid string conversion, the algorithm hinges on some math tricks. But it
prevents the inevitable O(n) of int-to-string conversion. Instead we can do what we
need to in O(n/2), though this is often expressed as O(n), it is still better!
Let's say your function is given the following int argument: 35753
First,
@adnauseum
adnauseum / dijkstra_two_stack.java
Last active July 16, 2018 22:24
Dijkstra's two-stack algorithm
/******************************************************************************
* Compilation: javac Evaluate.java
* Execution: java Evaluate
* Dependencies: Stack.java
*
* Evaluates (fully parenthesized) arithmetic expressions using
* Dijkstra's two-stack algorithm.
*
* % java Evaluate
* ( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )
/*
* HTTP over TLS (HTTPS) example sketch
*
* This example demonstrates how to use
* WiFiClientSecure class to access HTTPS API.
* We fetch and display the status of
* esp8266/Arduino project continuous integration
* build.
*
* Limitations: