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
use std::collections::{HashMap, HashSet}; | |
fn count_occurrences(message: &str) -> HashMap<char, usize> { | |
let unique: HashSet<char> = message.chars().collect(); | |
unique | |
.iter() | |
.map(|&c| (c, message.matches(c).count())) | |
.collect() | |
} |
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
// This file was initially generated by Windows Terminal 1.0.1401.0 | |
// It should still be usable in newer versions, but newer versions might have additional | |
// settings, help text, or changes that you will not see unless you clear this file | |
// and let us generate a new one for you. | |
// To view the default settings, hold "alt" while clicking on the "Settings" button. | |
// For documentation on these settings, see: https://aka.ms/terminal-documentation | |
{ | |
"$schema": "https://aka.ms/terminal-profiles-schema", |
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
async function fromCSV({ ctx }) => { | |
const { filePaths } = await dialog.showOpenDialog({ | |
filters: [{ name: "Comma seperated values", extensions: ["csv"] }], | |
}); | |
const csv = fs.readFileSync(filePaths[0], { encoding: "utf-8" }); | |
const lines = csv.split("\n"); | |
const keys = lines.shift()?.split(","); | |
for (const line of lines) { |
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
<button className="flex content-center items-center justify-center rounded-full border-2 border-transparent bg-sky-800 py-2 px-3 text-base leading-normal text-sky-100 outline-none hover:bg-opacity-80 focus:ring-1 focus:ring-offset-2 active:ring-0 active:ring-offset-0 disabled:cursor-not-allowed disabled:bg-opacity-50"> | |
<span className="mx-1">Alle</span> | |
<span className="relative inline-flex"> | |
<span className="mr-1 flex rounded-full bg-sky-500 px-2 py-1 text-xs font-bold uppercase"> | |
{filtercount} | |
</span> | |
<span | |
className="absolute inline-flex h-full w-full animate-ping rounded-full bg-sky-400 opacity-75" | |
style={{ | |
animationIterationCount: 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<button id="choose-file">choose a file to write to</button> |
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
{ | |
"$schema": "./drivers.schema.json", | |
"series": "f1", | |
"season": 2018, | |
"driverList": [ | |
{ | |
"raceNumber": 14, | |
"code": "ALO", | |
"firstName": "Fernando", | |
"lastName": "Alonso", |
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
use std::cmp::Ordering; | |
#[derive(Debug, PartialEq)] | |
pub enum Comparison { | |
Equal, | |
Sublist, | |
Superlist, | |
Unequal, | |
} |
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
use std::convert::TryFrom; | |
fn main() { | |
let names = vec!["Daniel", "Max", "Lewis"]; | |
let [daniel, max, lewis] = <[&str; 3]>::try_from(names).ok().unwrap(); | |
dbg!(daniel, max, lewis); | |
// daniel = "Daniel" | |
// max = "Max" |
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
#[derive(Debug)] | |
pub enum Bucket { | |
One, | |
Two, | |
} | |
impl Bucket { | |
fn other(&self) -> Self { | |
match self { | |
Bucket::One => Bucket::Two, |
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
let permutations = (0u8..10u8).permutations(letters.len()); | |
<!-- 105s --> | |
let possible_dicts: Vec<BTreeMap<char, u8>> = permutations | |
.filter_map(|permutation| { | |
let dict: BTreeMap<char, u8> = letters.iter().copied().zip(permutation).collect(); | |
if dict.iter().any(|(c, &n)| leading.contains(c) && n == 0) { | |
None | |
} else { | |
Some(dict) | |
} |
NewerOlder