Skip to content

Instantly share code, notes, and snippets.

View rpivo's full-sized avatar

Ryan Pivovar rpivo

  • New York City, NY
View GitHub Profile
@rpivo
rpivo / index.md
Last active July 8, 2021 20:45
Using `std::println` in Rust

Using std::println in Rust

Rust's std::println is similar to loggers in other languages.

fn main() {
    println!("Hello, world!"); // Hello, world!
}
@rpivo
rpivo / index.md
Last active July 6, 2021 19:33
Declaring Mutable & Immutable Variables in Rust

Declaring Mutable & Immutable Variables in Rust

We can declare mutable and immutable variables in Rust like so:

let foo = 0; // immutable
let mut bar = 1; // mutable

Note that immutability is the default. To make a variable mutable, we need to use the mut prefix.

@rpivo
rpivo / index.md
Last active July 7, 2021 22:34
Calling Static Methods in Rust

Calling Static Methods in Rust

You can call a non-instance static method in Rust by using the :: separator.

Example:

impl Solution {
    pub fn return_empty_string() -> String {
 // returns ""
@rpivo
rpivo / index.md
Last active July 6, 2021 18:50
Running a Rust File From the Command Line

Running a Rust File From the Command Line

To run a Rust file, say main.rs, you first need to compile it with rustc, which will produce an executable. Then you can run the executable.

rustc main.rs
./main

If a project is Cargo-ized, then you can use Cargo to compile it.

@rpivo
rpivo / index.md
Last active July 5, 2021 23:26
Checking the Currently Installed Version of Rust

Checking the Currently Installed Version of Rust

To check the version of the rustc compiler:

rustc --version

To check the version of rustup:

@rpivo
rpivo / index.md
Last active July 4, 2021 14:20
MySQL's Not Equal Operators

MySQL's Not Equal Operators

In MySQL (and MSSQL), there are two not equal operators: != and <>.

The following SQL schema will produce the table below.

Create table If Not Exists Employees (employee_id int, name varchar(30), salary int);
Truncate table Employees;
insert into Employees (employee_id, name, salary) values ('2', 'Meir', '3000');
@rpivo
rpivo / index.md
Last active July 5, 2021 14:45
Using the Main Function in Rust
@rpivo
rpivo / index.md
Last active July 3, 2021 13:52
Using the Left Function in MySQL

Using the Left Function in MySQL

The following SQL schema will produce the table below.

Create table If Not Exists Employees (employee_id int, name varchar(30), salary int);
Truncate table Employees;
insert into Employees (employee_id, name, salary) values ('2', 'Meir', '3000');
insert into Employees (employee_id, name, salary) values ('3', 'Michael', '3800');
insert into Employees (employee_id, name, salary) values ('7', 'Addilyn', '7400');
@rpivo
rpivo / index.md
Last active July 2, 2021 14:37
Conditional Statements in MySQL

Conditional Statements in MySQL

The following SQL schema will produce the table below.

Create table If Not Exists Employees (employee_id int, name varchar(30), salary int);
Truncate table Employees;
insert into Employees (employee_id, name, salary) values ('2', 'Meir', '3000');
insert into Employees (employee_id, name, salary) values ('3', 'Michael', '3800');
insert into Employees (employee_id, name, salary) values ('7', 'Addilyn', '7400');
@rpivo
rpivo / index.md
Last active June 30, 2021 17:01
Common Analytics KPIs

Common Analytics KPIs

Name Description
Dwell Time The total time that an issue has been present until it is fixed.
Mean Time Between Failures (MTBF) Average amount of time that elapses between failures.
Mean Time to Detect (MTTD) Average amount of time it takes to discover an issue.
Mean Time to Failure (MTTF) Average amount of time it takes for a system to fail while the issue is present.
Mean Time to Respond (MTTR) Average amount of time it takes to fix an issue once it's found.