View jarvis.py
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
""" | |
GPT-3 British Voice Assistant | |
This project is a simple voice assistant that takes your natural speech as input | |
and returns a response generated by the GPT-3 AI model. The response is then | |
read out loud with a British accent. | |
Installation: | |
1. Create a virtual environment and activate it: |
View main.rs
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 s = "system/{id}/start/{mode}"; | |
let substrings = extract_substrings(s); | |
assert_eq!(substrings, vec!["id", "mode"]); | |
let removed = remove_substrings(&s, &substrings); | |
assert_eq!(removed, "system/{}/start/{}"); | |
} | |
fn extract_substrings(s: &str) -> Vec<&str> { |
View main.rs
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 input = "UpperCamelCase"; | |
let snake_case = to_snake_case(input); | |
println!("{}", snake_case); | |
} | |
fn to_snake_case(input: &str) -> String { | |
input | |
.chars() | |
.enumerate() |
View numbered-placeholders.rs
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 input = "Some string {} another value {} third value {}"; | |
let output = numbered_placeholders(input); | |
let expected_output = "Some string {0} another value {1} third value {2}"; | |
assert_eq!(output, expected_output); | |
} | |
fn numbered_placeholders(s: &str) -> String { | |
let mut counter = 0; | |
let mut result = String::new(); |
View adjacency_list.rs
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 compact graph representation. Edges are numbered in order of insertion. | |
/// Each adjacency list consists of all edges pointing out from a given vertex. | |
pub struct Graph { | |
/// Maps a vertex id to the first edge in its adjacency list. | |
first: Vec<Option<usize>>, | |
/// Maps an edge id to the next edge in the same adjacency list. | |
next: Vec<Option<usize>>, | |
/// Maps an edge id to the vertex that it points to. | |
endp: Vec<usize>, | |
} |
View test.rs
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::{sync::mpsc, thread, time::Duration}; | |
#[test] | |
fn oops() { | |
panic_after(Duration::from_millis(100), || { | |
thread::sleep(Duration::from_millis(200)); | |
}) | |
} | |
fn panic_after<T, F>(d: Duration, f: F) -> T |
View most-lines-added.ps1
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
git log --shortstat --author="Matthew J. Berger" --pretty=format:"%H - %an, %ar : %s" | foreach { | |
if ($_ -match '([0-9a-fA-F]{40})') { | |
$commitHash = $matches[1] | |
} | |
if ($_ -match '(\d+)\s+insertion\S*.*(\d+)\s+deletion\S*') { | |
$insertions = [int]$matches[1] | |
$deletions = [int]$matches[2] | |
[pscustomobject]@{ | |
CommitHash = $commitHash | |
Insertions = $insertions |
View Cargo.toml
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
[package] | |
name = "window" | |
version = "0.1.0" | |
edition = "2021" | |
[dependencies] | |
winit = "0.28.1" | |
async-std = "1.10.0" |
View layered.rs
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
// Layer 1: Domain | |
#[derive(Clone)] | |
pub struct User { | |
pub id: i32, | |
pub name: String, | |
pub email: String, | |
} | |
// Layer 2: Data Access | |
pub trait UserRepository { |
View udev.sh
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
udevadm monitor |
NewerOlder