Skip to content

Instantly share code, notes, and snippets.

@SwannHERRERA
SwannHERRERA / clean-archi-4.rs
Created February 17, 2023 13:15
This program takes a file name as argument and an operation (+, - or *) it parses the file in this file, each line of the file should hopefully have a valid number it should take each number and print the operation, along with the intermediary result it should print at the end the total result of the defined operation applied to all numbers fou…
use std::env;
pub enum Operator {
Add,
Subtract,
Multiply,
Divide,
}
// TODO create an object that store state
@SwannHERRERA
SwannHERRERA / GuessTheNumber.java
Created February 16, 2023 16:26
5AL2 exercices form clean architecture courses
public class App {
public static void main(String[] args) {
GuessTheNumber guessTheNumber = new GuessTheNumber();
guessTheNumber.main(args);
}
}
public class GameConfig {
public static final int MAX_ATTEMPTS = 10;
public static final int MAX_NUMBER = 100;
@SwannHERRERA
SwannHERRERA / do-while-loop.rs
Created June 18, 2022 12:38
rust do while loop
macro_rules! do_loop {(
$body:block while $cond:expr
) => ({
let mut first = true;
while ::core::mem::replace(&mut first, false) || $cond
$body
})}
let mut x = 6;
do_loop!({
@SwannHERRERA
SwannHERRERA / main.rs
Created October 2, 2021 21:51
demo-thread-rust
// use std::sync::Mutex;
use std::thread;
use std::time::Duration;
fn main() {
let mut handles = vec![];
let fifty_millis = Duration::from_millis(50);
let forty_millis = Duration::from_millis(40);
let twenty_millis = Duration::from_millis(20);
let time_printing_underscore = Duration::from_secs(10);