This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createBencher(iters) { | |
return function runBench(label, fn) { | |
console.time(label); | |
for (let i = 0; i < iters; i++) { | |
fn(); | |
} | |
console.timeEnd(label); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @ts-check | |
/** | |
* Lightens a color. | |
* @param {string} color - Hexadecimal number string of color. | |
* @param {number} [ratio=0.5] - Strength of effect. | |
* @returns {(string | null)} 6-digit hexadecimal number string of result. | |
*/ | |
export function lighten(color, ratio = 0.5) { | |
ratio = clampRatio(ratio); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @brief Checks if a string ends with a given suffix. | |
* | |
* @param fullString The string to check. | |
* @param ending The suffix to check for. | |
* @return True if the string ends with the suffix, false otherwise. | |
*/ | |
bool hasEnding(std::string const &fullString, std::string const &ending) { | |
// Sourced from https://stackoverflow.com/questions/874134/find-out-if-string-ends-with-another-string-in-c | |
int fullStringLen = fullString.length(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -ss 00:01:07 -i input.mkv -t 00:28:26 -vcodec copy -acodec copy -avoid_negative_ts make_zero output.mkv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*Format lines: | |
* awk -i inplace '{printf("%04d00%s\n", NR, substr($0,7,120)) }' main.cbl | |
*Compile and run: | |
* cobc -x main.cbl && ./main | |
IDENTIFICATION DIVISION. | |
PROGRAM-ID. hello. | |
AUTHOR. Julia. | |
DATE-WRITTEN. 2024-04-19. | |
DATE-COMPILED. 2024-04-19. | |
REMARKS. This is a pretty good COBOL program. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
000100*Condensed from 01-06 https://www.youtube.com/watch?v=m0HfCx1wg1g | |
000200*AAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBIIIIIIII | |
000300 IDENTIFICATION DIVISION. | |
000400 PROGRAM-ID. hello. | |
000500 AUTHOR. JULIA. | |
000600 DATE-WRITTEN. 2024-04-16. | |
000700 DATE-COMPILED. 2024-04-16. | |
000800 REMARKS. This is a pretty good COBOL program. | |
000900* | |
001000 ENVIRONMENT DIVISION. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
000100*AAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBIIIIIIII | |
000150*Format lines: | |
000151* awk -i inplace '{printf("%04d00%s\n", NR, substr($0,7,120)) }' main.cbl | |
000160*Compile and run: | |
000161* cobc -x main.cbl && ./main | |
000200 IDENTIFICATION DIVISION. | |
000400 PROGRAM-ID. hello. | |
000500 AUTHOR. JULIA. | |
000600 DATE-WRITTEN. 2024-04-14. | |
000700 DATE-COMPILED. 2024-04-14. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: | |
// https://github.com/Nicklason/node-tf2-currencies | |
const ONE_REF_SCRAP = 9; | |
// Convert a number in refined to scrap | |
function toScrap(refined) { | |
return Math.round(refined * ONE_REF_SCRAP); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A possibly more efficient way to match pluralized strings case-insensitively. | |
// For example matching "burgers" and "burger" with fewer iterations. | |
// Untested | |
fn eq_ignore_ascii_case_with_tail(mut lhs: &str, rhs: &str, tail: char) -> bool { | |
let mut lhs_len = lhs.len(); | |
let rhs_len = rhs.len(); | |
if lhs_len == rhs_len + 1 && lhs.ends_with(tail) { | |
lhs = &lhs[..lhs_len - 1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Filtered = Symbol('Filtered'); | |
const Break = Symbol('Break'); | |
class CharIterator { | |
constructor(string) { | |
this.string = string; | |
this.index = 0; | |
} | |
NewerOlder