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
#!/usr/bin/env deno run --unstable-kv --allow-read --allow-write | |
// deno-lint-ignore-file prefer-const | |
import { parseArgs } from "jsr:@std/cli"; | |
let db = await Deno.openKv("incrementer"); | |
if (import.meta.main) { | |
let args = parseArgs(Deno.args); | |
let ns = args["_"][0] ?? "_global"; |
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
import opentelemetry from "npm:@opentelemetry/api"; | |
import { context, trace } from "npm:@opentelemetry/api"; | |
import { | |
BasicTracerProvider, | |
BatchSpanProcessor, | |
ConsoleSpanExporter, | |
SimpleSpanProcessor, | |
} from "npm:@opentelemetry/sdk-trace-base"; | |
import { Resource } from "npm:@opentelemetry/resources"; | |
import { OTLPTraceExporter } from "npm:@opentelemetry/exporter-trace-otlp-proto"; |
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
fn main() { | |
let highest = vec!["apple", "banana", "cherry", "date", "fig"] | |
.into_iter() | |
.map(|w| (w, score(w.to_owned()))) | |
.reduce(|acc, b| { | |
if b.1 > acc.1 { | |
return b; | |
} | |
acc | |
}) |
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
// Given two strings s and t, determine if they are isomorphic. | |
// Two strings are isomorphic if there is a one-to-one mapping | |
// possible for every character of the first string to every | |
// character of the second string. | |
function isIsomorphic(a, b) { | |
if (a.length !== b.length) return false; | |
let mapping = {}; | |
for (let i = 0; i < a.length; i++) { |
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
// md-fmt takes a csv or tsv input file and outputs a formatted markdown table | |
// with the data. | |
package main | |
import ( | |
"encoding/csv" | |
"flag" | |
"fmt" | |
"log" | |
"os" |
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
fn main() { | |
println!("{}", validate(vec![1, 2, 3, 4, 5, 6, 7, 8, 9])); | |
} | |
fn validate(card: Vec<u8>) -> bool { | |
let mut card = card; | |
let given_check = card.pop().unwrap(); | |
let mut check = 0; | |
for (i, n) in card.iter().rev().enumerate() { |
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
/** | |
* Write a function that takes an array of consecutive, increasing letters as | |
* input, and returns any missing letters in the array between the first and | |
* last letter. | |
* | |
* Example: | |
* ``` | |
* > missingLetters(['a','b','c','d','f']) | |
* > ['e'] | |
* |
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 rows = [ | |
"qwertyuiop", | |
"asdfghjkl", | |
"zxcvbnm", | |
].reduce( | |
(acc, curr, i) => { | |
curr.split('').forEach(c => acc[c] = i); | |
return acc; | |
}, | |
{}, |
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
#!/usr/bin/env deno run -A | |
import { readStringDelim } from "https://deno.land/std@0.186.0/io/read_string_delim.ts"; | |
import * as path from "https://deno.land/std@0.186.0/path/mod.ts"; | |
async function extractMetricNames(f) { | |
const filename = path.join(Deno.cwd(), f); | |
let fileReader = await Deno.open(filename); | |
let metrics = new Set(); |
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
/// Given a non-empty array containing only non-negative integers, return the | |
/// list with trailing and leading zeroes removed. | |
/// | |
/// Example: | |
/// | |
/// ``` | |
/// > removeZeroes([0, 0, 0, 3, 1, 4, 1, 5, 9, 0, 0, 0, 0]) | |
/// > [3, 1, 4, 1, 5, 9] | |
/// | |
/// > removeZeroes([0, 0, 0]) |
NewerOlder