This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use inquire::{validator::Validation, CustomType}; | |
use std::path::{self, Path}; | |
fn full_path(p: String) -> String { | |
path::absolute(p.as_str()) | |
.unwrap() | |
.canonicalize() | |
.unwrap() | |
.to_str() | |
.unwrap() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs::File; | |
enum ComeWith<T, E> { | |
YouBetcha(T), | |
Ope(E), | |
} | |
impl<T, E> From<std::result::Result<T, E>> for ComeWith<T, E> { | |
fn from(r: std::result::Result<T, E>) -> Self { | |
match r { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import pandas as pd | |
def getDataframe(url_table, ind): | |
df = pd.read_html(url_table)[ind] | |
return df | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// rust has pretty print support for printing structures. this is how rust's proc_macros | |
// parse the following struct: | |
// | |
// pub struct Book { | |
// id: u64, | |
// title: String, | |
// pages: u64, | |
// author: String, | |
// } | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use proc_macro::TokenStream; | |
use quote::quote; | |
use syn::{ | |
parse_macro_input, Data::Struct, DataStruct, DeriveInput, Field, Fields::Named, FieldsNamed, | |
Path, Type, TypePath, | |
}; | |
#[derive(Debug)] | |
struct DBModel { | |
name: String, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default: | |
just -l | |
lsvm: | |
limactl ls | |
mkvm id: | |
limactl create \ | |
--name="{{id}}" \ | |
--vm-type=vz \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Output: | |
// HASH: "$argon2id$v=19$m=19456,t=2,p=1$vecn7S39OC1B7Ei0ZBfl1A$q94uWmUFrtuUhERwWCLkCGSO+CRZwGEWUTmJSO8wr0c" | |
// ACCESS VERIFIED | |
use anyhow::{Context, Result}; | |
use argon2::{password_hash::SaltString, Argon2, PasswordHash}; | |
async fn hash_password(password: String) -> Result<String> { | |
tokio::task::spawn_blocking(move || -> Result<String> { | |
let salt = SaltString::generate(rand::thread_rng()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Polygon struct { | |
Sides int | |
} | |
func (p *Polygon) NSides() int { | |
return p.Sides |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(clippy::upper_case_acronyms)] | |
// a trait for describing vehicles that can move on land | |
trait LandCapable { | |
// a function with no implementation acts as an interface | |
//fn drive(&self); | |
// default imlpementation | |
fn drive(&self) { | |
println!("Default drive"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Output looks like this: | |
# | |
# $ python ./kmeans.py | |
# Centroids: [[14, 17], [17, 7], [3, 15]] | |
# Done: [[17.5, 16.5], [16.5, 4.166666666666667], [1.8, 1.6]] | |
# 0: [[15, 14], [18, 14], [20, 20], [17, 18]] | |
# 1: [[12, 10], [20, 0], [19, 2], [18, 1], [11, 9], [19, 3]] | |
# 2: [[0, 1], [1, 1], [2, 2], [3, 3], [3, 1]] |