Skip to content

Instantly share code, notes, and snippets.

View KyleMit's full-sized avatar

Kyle Mitofsky KyleMit

View GitHub Profile
@KyleMit
KyleMit / birthday.js
Last active April 9, 2024 12:27
Birthday Prize Simulation
main()
function main() {
var prizes = [-1, -1, -1, 1, 1, 2, 2, 2, 3, 3, 5, 5, 5, 5, 5, 20, 20, 20, 20, 20, 20, 40, 40, 40, 60, 100];
var simulationResults = Array.from({ length: prizes.length }, (_, i) => simulateTurns(prizes, i + 1));
console.log(simulationResults);
}
function simulateTurns(prizes, selectionCount = 15, turns = 10000) {
let winningsForAllTurns = Array.from({ length: turns }, () => simulateGame(prizes, selectionCount));
@KyleMit
KyleMit / Program.cs
Created March 5, 2023 16:58
Performance Benchmarks for Testing [a-Z]
using System;
using System.Linq;
using System.Text.RegularExpressions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<TestAlphaCheck>();

Rebasing a branch of a branch after squash merging

Here's a question I asked on slack recently:

When we do a branch off a branch,
and then squash commit the original,
is there a way to get the original commits to not show up on the new PR?

It's a a scenario that comes up not infrequently...

@KyleMit
KyleMit / rename-main.md
Created February 18, 2022 21:44
Rename Default Branch to Main
@KyleMit
KyleMit / index.html
Last active June 9, 2021 03:38
Loading Spinner Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Loading Spinner Example</title>
<link rel="stylesheet" href="./style.css">
@KyleMit
KyleMit / index.html
Last active July 26, 2022 08:23
Walker's Algorithm
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">
<title>Walkers</title>
</head>
<body>
<header>
@KyleMit
KyleMit / find-index.js
Created October 26, 2020 15:59
Twitter - Find Index
let pets = [
{ name: "Ranger", type: "Dog" },
{ name: "Gill", type: "Cat" },
{ name: "Frida", type: "Cat" }
]
let startWithGIndex = pets.findIndex(el => el.name.startsWith("G"))
console.log(nameStartWithGIndex) // 1
@KyleMit
KyleMit / variadic-function.js
Created October 26, 2020 15:49
Twitter - Variadic Function
let checkValInList = (val, ignoreCase, ...list) => {
return ignoreCase
? list.some(el => el.toLowerCase() === val.toLowerCase())
: list.includes(val)
}
checkValInList("hello", true, "Hi", "Hello", "Howdy") // true
checkValInList("hello", false, "Hi", "Hello", "Howdy") // false
@KyleMit
KyleMit / includes.js
Created October 26, 2020 15:34
Twitter - Includes
console.log(~"apple".indexOf("a")) // true
console.log("apple".indexOf("a") >= 0) // true
console.log("apple".includes("a")) // true
@KyleMit
KyleMit / autocomplete.html
Created October 26, 2020 14:45
Twitter - Autocomplete
<div>
<label for="old-pass">Current Password:</label>
<input type="password" id="old-pass" autocomplete="current-password">
</div>
<div>
<label for="new-pass">Choose New Password:</label>
<input type="password" id="new-pass" autocomplete="new-password">
</div>