Skip to content

Instantly share code, notes, and snippets.

View mehmetsefabalik's full-sized avatar
🐟

Mehmet Sefa mehmetsefabalik

🐟
View GitHub Profile
use chrono;
use chrono::offset::TimeZone;
let birth_date = chrono::Utc.from_local_date(&chrono::NaiveDate::parse_from_str("1995-07-05", "%Y-%m-%d")).unwrap();
let duration_since_birth = chrono::Utc::today().signed_duration_since(birth_date);
let age = duration_since_birth.num_days() / 365
@mehmetsefabalik
mehmetsefabalik / sort-vec-of-tuples.rs
Created July 11, 2021 14:30
Sort Vector of Tuples in Rust
fn main() {
let mut v: Vec<(&str, i32)> = vec![("a", 2), ("b", 1), ("c", 3)];
v.sort_by(|a, b| a.1.cmp(&b.1)); // increasing order
v.sort_by(|a, b| b.1.cmp(&a.1)); // decreasing order
println!("{:?}", v);
}
@mehmetsefabalik
mehmetsefabalik / nginx-https-local.md
Last active April 28, 2024 07:37
Enable https on your local environment with nginx

enable https on your local environment

install mkcert and create certificates

brew install mkcert
mkcert -install