Skip to content

Instantly share code, notes, and snippets.

View audunolsen's full-sized avatar
🌷
Made a new avatar with Midjourney lmao

Audun Meek Olsen audunolsen

🌷
Made a new avatar with Midjourney lmao
View GitHub Profile
import java.util.Scanner;
public class Menu {
public static void main(String[] args) {
promptUser();
}
static void promptUser() {
Scanner scanner = new Scanner(System.in);
private static void ParseFindings(String input) {
Scanner scanner = new Scanner(input);
List<List<String>> discoveries = new ArrayList<>();
int discoveryIndex = 0;
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
if (discoveryIndex >= discoveries.size()) {
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class PopulateDatabase {
// Main for del 1
public static void main(String[] args) {
@audunolsen
audunolsen / App.tsx
Created February 14, 2024 11:28
Sticky icons drawer scrollable both axis
function App() {
return (
<div className={styles.container}>
{/* */}
{/* */}
<div className={styles.blockScroller}>
{/* */}
{/* */}
<div className={styles.inlineScroller}>
<div className={styles.drawer}>
import { useReducer, type Reducer, useEffect, useRef, useMemo } from 'react';
import { useConst } from '../hooks';
/**
* For when side effects are needed using React's built in useReducer.
* You can listen to dispatched events and fire callbacks when the state is updated.
*
* @note
* - Only criteria is that events/actions are typed as objects w a required `type` field.
*
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
html, body {
height: 100%;
min-height: 100%;
/*
* Here's an alternative approach that uses the ternary operator instead of `if/else`.
* It does just the same as the other example just expressed slightly differently.
*
* DOCS: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_operator
*/
const secret = "coconut"
const guess = prompt()
const response = guess === secret ? "Ding ding!!" : "Nope…"
import { HasKeys, IsEmpty, RequiredFields } from "."
export type OptionalIfEmpty<T> = [
...(IsEmpty<T> extends true
? [never?]
: HasKeys<RequiredFields<T>> extends true
? [T]
: [T?])
]
import { useMemo, useReducer } from "react"
import produce, { castImmutable } from "immer"
import { isEqual } from "lodash-es"
import { NonEmpty } from "~utils/types"
interface SetValue<T> {
<K extends keyof T>(
next: NonEmpty<Pick<T, K>> | null,
restoreInitial?: boolean
): void
// hmmmmm loop arbitrary iteration count
for (const [index] of Array(len).entries()) {
console.log(index)
}
for (const index of Array(len).keys()) {
console.log(index)
}