Skip to content

Instantly share code, notes, and snippets.

let mut file = std::fs::OpenOptions::new()
.write(true)
.append(false)
.create(true)
.open("/home/ebresafegaga/server.log")
.unwrap();
let data = format!("{:?}", linearization.linearization);
std::io::Write::write(&mut file, data.as_ref()).unwrap();
@ebresafegaga
ebresafegaga / trash.rs
Created December 5, 2022 21:31
Trash code
fn parse_crate<'a, I>(chs: &'a mut I) -> Option<char>
where
I: Iterator<Item = char>,
{
fn is_for_crate<'a, I>(c: char, chs: &'a mut I) -> bool
where
I: Iterator<Item = char>,
{
if c == '[' || c == ']' {
true
@ebresafegaga
ebresafegaga / path.rs
Last active December 23, 2022 09:57
Path
let path: String = path.chars().skip_while(|ch| !(ch.is_alphanumeric() || *ch == '-' || *ch == '_')).collect();
//
// ("Paren before ident", "(record", vec!["record"])
let (next, _) = linearization.get_items_adjacent(parent.id);
let next = next.and_then(|item| match item.kind {
TermKind::RecordField {
ident,
record,
value: ValueState::Known(value),
..
} if value == parent.id => Some((ident, record)),
_ => None,
});
@ebresafegaga
ebresafegaga / camel_to_kebab.ml
Last active March 28, 2023 16:00
Camel to Kebab
(* camel_to_kebab('CamelCaseString') == 'camel-case-string'
camel_to_kebab('CamelCaseStringWithABREV') == 'camel-case-string-with-abrev'
camel_to_kebab('CamelCaseStringWithABREVInCenter') == 'camel-case-string-with-abrev-in-center' *)
(* words = re.findall('([A-Z][a-z]+)|([A-Z]+(?=[A-Z][a-z]+))', s) *)
type state =
| Start
| InsideCamel
| InsideAbrev
type stack = int array
type machine = { ip : int; sp : int; mutable stack : stack }
(* Machine stack *)
module type S = sig
type t
type index
type elem
@ebresafegaga
ebresafegaga / main.ml
Created October 24, 2023 18:02
Trying out Domainslib
let long_computation () =
for i = 0 to 1_000_000_000 do
()
done
(* No parallelism *)
(*
________________________________________________________
Executed in 36.09 secs fish external
usr time 36.08 secs 1.27 millis 36.08 secs