Skip to content

Instantly share code, notes, and snippets.

View Marmiz's full-sized avatar

Claudio Restifo Marmiz

View GitHub Profile
@Marmiz
Marmiz / main.rs
Last active March 4, 2024 19:12
Final section of todo-cli
use std::collections::HashMap;
fn main() {
let action = std::env::args().nth(1).expect("Please provide an action");
let item = std::env::args().nth(2).expect("Please provide an item");
let mut todo = Todo::new().expect("Initialisation of db failed");
if action == "add" {
todo.insert(item);
@Marmiz
Marmiz / main.rs
Created December 29, 2020 11:13
Third section of todo-cli in Rust
use std::collections::HashMap;
use std::io::Read;
use std::str::FromStr;
fn main() {
let action = std::env::args().nth(1).expect("Please specify an action");
let item = std::env::args().nth(2).expect("Please specify an item");
let mut todo = Todo::new().expect("Initialisation of db failed");
@Marmiz
Marmiz / main.rs
Created December 26, 2020 15:35
Second portion of to-do cli in Rust
use std::collections::HashMap;
use std::io::Read;
use std::str::FromStr;
fn main() {
let action = std::env::args().nth(1).expect("Please specify an action");
let item = std::env::args().nth(2).expect("Please specify an item");
let mut todo = Todo::new().expect("Initialisation of db failed");
@Marmiz
Marmiz / main.rs
Created December 26, 2020 14:45
First portion of to-do cli in Rust
use std::collections::HashMap;
fn main() {
let action = std::env::args().nth(1).expect("Please specify an action");
let item = std::env::args().nth(2).expect("Please specify an item");
let mut todo = Todo {
map: HashMap::new(),
};
if action == "add" {
@Marmiz
Marmiz / exercise.tour.go
Created July 13, 2017 09:24
Exercise made during A Tour of Go.
/*
* Exercise: Loops and Functions
* As a way to play with functions and loops, implement the square root function using Newton's method.
* To begin with, repeat the calculation 10 times and see how close you get to the answer for various values (1, 2, 3, ...).
* Next, change the loop condition to stop once the value has stopped changing (or only changes by a very small amount).
* See if that's more or fewer than 10 iterations. How close are you to the math.Sqrt?
*/
package main