From 6db7d9edf7ffb462cee4cfdbbe340910bd154ddf Mon Sep 17 00:00:00 2001 From: Luke Tidd Date: Thu, 15 Dec 2022 12:25:57 -0500 Subject: [PATCH] added notes did more stuff --- array_access/Cargo.toml | 8 ++++ array_access/src/main.rs | 18 +++++++++ notes | 83 ++++++++++++++++++++++++++++++++++++++++ tuple1/Cargo.toml | 8 ++++ tuple1/src/main.rs | 6 +++ win_oops | 23 +++++++++++ 6 files changed, 146 insertions(+) create mode 100644 array_access/Cargo.toml create mode 100644 array_access/src/main.rs create mode 100644 notes create mode 100644 tuple1/Cargo.toml create mode 100644 tuple1/src/main.rs create mode 100644 win_oops diff --git a/array_access/Cargo.toml b/array_access/Cargo.toml new file mode 100644 index 0000000..5378f9b --- /dev/null +++ b/array_access/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "array_access" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/array_access/src/main.rs b/array_access/src/main.rs new file mode 100644 index 0000000..0aa3f68 --- /dev/null +++ b/array_access/src/main.rs @@ -0,0 +1,18 @@ +use std::io; + +fn main() { + let a = [1, 2, 3, 4, 5]; + let mut index = String::new(); + io::stdin() + .read_line(&mut index) + .expect("doh"); + let index: usize = index + .trim() + .parse() + .expect("notta num"); + + let element = a[index]; + + println!("you gotta {element}"); + +} diff --git a/notes b/notes new file mode 100644 index 0000000..4c39058 --- /dev/null +++ b/notes @@ -0,0 +1,83 @@ +const is a thing +const convention is all upper with _ +const evaluation info: https://doc.rust-lang.org/reference/const_eval.html + +you can add arbitray scopes to modify local variables or for other purposes! + { + some random shit; + } + +https://doc.rust-lang.org/book/ch03-02-data-types.html + +scalars: + ints + floats + bools + chars +integer types: + 8-bit i8 u8 + 16-bit i16 u16 + 32-bit i32 u32 + 64-bit i64 u64 + 128-bit i128 u128 + arch isize usize + +number literals +decimal 1_024 +hex 0xff +oct 0o77 +binary 0b1100_1011_0100_0001 +byte b'E' + +release builds have no overflow wrap checking +don't rely on this behavior + +explicitly use +`wrapping_*` methods to do this + such as wrapping_add +Return the None value if there is overflow with the checked_* methods +Return the value and a boolean indicating whether there was overflow with the overflowing_* methods + +wtf is this: + Saturate at the value’s minimum or maximum values with saturating_* methods + +there are f32 and f64 floats. f64 is default cause they are about the same speed + +normal math operators +int division is floor +remainder % exists + +all operators: +https://doc.rust-lang.org/book/appendix-02-operators.html + + +type annotation: + +let var: type = val; + +Rust’s char type is four bytes in size and represents a Unicode Scalar Value + +Compound types + + primitive compound types: + tuples + arrays + +Tuples: + fixed length combo of types + type is () + + pulling out the elements of a tuple into individual variables is called destructuring + +Arrays: + fixed type fixed length + [] + + init: + let a: [1, 2, 3]; + let a: [3, 0]; // set every element to same value + reference: + let first = a[0]; + they are allocated on stack + + diff --git a/tuple1/Cargo.toml b/tuple1/Cargo.toml new file mode 100644 index 0000000..d63cf88 --- /dev/null +++ b/tuple1/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "tuple1" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/tuple1/src/main.rs b/tuple1/src/main.rs new file mode 100644 index 0000000..03f583e --- /dev/null +++ b/tuple1/src/main.rs @@ -0,0 +1,6 @@ +fn main() { + let x: (i32, f64, u8) = (500, 6.4, 1); + let _five_hundred = x.0; + let _six_point_four = x.1; + let _one = x.2; +} diff --git a/win_oops b/win_oops new file mode 100644 index 0000000..fc2172a --- /dev/null +++ b/win_oops @@ -0,0 +1,23 @@ +12/13/2022 05:09 AM . +chrome-admin@V-WTEST-1-G580 C:\Users\chrome-admin>castore -ssl-dir C:/ProgramData/PuppetLabs/puppet/etc/ssl -token-type GOLO -bootstrap-token C:\token -caname "ChOps Puppet CA" -hostname v-wtest-1-g580.golo.chromi +um.org +[I2022-12-13T05:11:25.075236-08:00 7216 0 main.go:235] Creating client for: https://cert-factory.appspot.com +[I2022-12-13T05:11:25.075236-08:00 7216 0 main.go:267] ssldir is "C:/ProgramData/PuppetLabs/puppet/etc/ssl" +[I2022-12-13T05:11:26.591212-08:00 7216 0 main.go:430] created a cert request - task_id:"13ff16e2c9767d2ec976ff86125c6ab49156dd6d" +[I2022-12-13T05:11:31.707891-08:00 7216 0 main.go:451] got signed certs back for - task_id:"13ff16e2c9767d2ec976ff86125c6ab49156dd6d" +[I2022-12-13T05:11:31.871587-08:00 7216 0 main.go:506] done! Created certs and placed in "C:/ProgramData/PuppetLabs/puppet/etc/ssl/certs" +[I2022-12-13T05:11:31.871587-08:00 7216 0 main.go:193] castore took 6.8050602s to run + +chrome-admin@V-WTEST-1-G580 C:\Users\chrome-admin>puppet agent -t +Info: Using environment 'production' +Error: certificate verify failed [certificate has expired for CN=puppet3-g.golo.chromium.org] +Info: Loading facts +The system cannot find the path specified. +Error: Could not retrieve catalog from remote server: certificate verify failed [certificate has expired for CN=puppet3-g.golo.chromium.org] +Warning: Not using cache on failed catalog +Error: Could not retrieve catalog; skipping run +Error: Could not send report: certificate verify failed [certificate has expired for CN=puppet3-g.golo.chromium.org] + +chrome-admin@V-WTEST-1-G580 C:\Users\chrome-admin>puppet config print ssldir +C:/ProgramData/PuppetLabs/puppet/etc/ssl +