Skip to content

Instantly share code, notes, and snippets.

View MarinPostma's full-sized avatar

ad hoc MarinPostma

  • turso
  • prague
View GitHub Profile
@MarinPostma
MarinPostma / test.rs
Last active September 12, 2023 15:56
tokio run_until bug
use std::time::Duration;
use tokio::task::LocalSet;
fn main() {
let mut builder = tokio::runtime::Builder::new_current_thread();
let tokio = builder.enable_time().start_paused(true).build().unwrap();
let local = LocalSet::new();
let fut = async move {
tokio::task::spawn_blocking(move || {
use std::borrow::Cow;
use std::ops::Deref;
use std::collections::HashSet;
use std::fs::File;
use std::mem::{size_of, transmute};
use std::os::unix::prelude::FileExt;
use bytemuck::{Zeroable, Pod, pod_read_unaligned, bytes_of, try_from_bytes};
use bytes::{BytesMut, Bytes};
@MarinPostma
MarinPostma / lazy_entity.ts
Last active September 20, 2022 10:11
POC lasy chisel entities
abstract class ChiselEntity {
__data: any;
__ctx_id: number;
public Ready: Promise.IThenable<any>;
public isReady = false;
}
class Person extends ChiselEntity {
// these just end up as dummies
name: string;
This file has been truncated, but you can view the full file.
[START][2021-11-01 14:12:20] LSP logging initiated
[START][2021-11-01 14:12:30] LSP logging initiated
[START][2021-11-01 14:13:10] LSP logging initiated
[START][2021-11-01 14:15:34] LSP logging initiated
[START][2021-11-01 14:16:09] LSP logging initiated
[START][2021-11-01 14:16:22] LSP logging initiated
[START][2021-11-01 14:16:46] LSP logging initiated
[START][2021-11-01 14:17:05] LSP logging initiated
[START][2021-11-01 14:17:59] LSP logging initiated
[START][2021-11-01 14:18:13] LSP logging initiated
@MarinPostma
MarinPostma / main.rs
Created September 8, 2021 18:51
meili nom parser
use nom::{IResult, branch::alt, bytes::complete::{take_while1, tag}, character::complete::{char, multispace0}, combinator::map, error::ParseError, multi::many0, sequence::{delimited, tuple, preceded}};
fn is_key_component(c: char) -> bool {
c.is_alphanumeric() || ['_', '-', '.'].contains(&c)
}
fn parse_key(input: &str) -> IResult<&str, &str> {
let key = |input| take_while1(is_key_component)(input);
alt((key, delimited(char('"'), key, char('"'))))(input)
}
@MarinPostma
MarinPostma / main.rs
Created September 8, 2021 18:10
nom meili parser
use nom::{
IResult,
character::complete::{char, multispace0},
combinator::map,
branch::alt,
sequence::{delimited, tuple, preceded},
multi::many0,
bytes::complete::{take_while1, tag},
};
use std::collections::VecDeque;
use std::time::Instant;
use std::time::{SystemTime, UNIX_EPOCH};
use tokio::select;
use tokio::stream::StreamExt;
use tokio::time::{self, Duration};
#[derive(Debug)]
struct Website {
pub url: String,
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.Line2D;
import java.util.ArrayList;
import java.util.List;
public class test {
public static void main(String args[]) {