This file contains hidden or 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
// <expression ::= <term> { ("+" | "-") <term> } | |
// <term> ::= <factor> { ("*" | "/") <factor> } | |
// <factor> ::= <number> | "(" <expression> ")" | |
// <number> ::= <digit> { <digit> } | |
// <digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | |
use std::str::FromStr; | |
#[derive(Debug, PartialEq, Clone)] | |
pub enum Token { |
This file contains hidden or 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
// TOTAL CHUNKS: 5 | |
// - chunk: 5242880 | |
// - chunk: 5242880 | |
// - chunk: 5242880 | |
// - chunk: 5242880 | |
// - chunk: 1974756 | |
use tokio::{fs::File, io, io::AsyncReadExt, io::AsyncSeekExt}; | |
pub async fn read_chunk(file_path: &str, start: u64, end: u64) -> io::Result<Vec<u8>> { |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |