Skip to content

Instantly share code, notes, and snippets.

@tivrfoa
tivrfoa / instructions.md
Created March 16, 2024 01:42 — forked from matthewjberger/instructions.md
Install a nerd font on ubuntu

1.) Download a Nerd Font

2.) Unzip and copy to ~/.fonts

3.) Run the command fc-cache -fv to manually rebuild the font cache

@tivrfoa
tivrfoa / city-jel.txt
Created January 13, 2024 11:36
1brc sin city
jel;18.6
jel;12.8
jel;20.7
jel;13.8
jel;26.7
jel;17.7
jel;24.7
jel;18.4
jel;10.7
jel;21.9
@tivrfoa
tivrfoa / trial1.rs
Created November 30, 2023 00:59
Circular Linked List in Rust
use std::rc::Rc;
use std::cell::RefCell;
#[derive(Debug)]
struct Node {
n: u32,
next: Option<Rc<RefCell<Node>>>,
}
type NodeT = Option<Rc<RefCell<Node>>>;
@tivrfoa
tivrfoa / rust-cell-interior-mutability.rs
Created November 28, 2023 21:02
Rust Cell Interior Mutability
use std::cell::Cell;
#[derive(Debug)]
struct Node {
n: usize,
next: Cell<usize>,
}
fn main() {
let nodes = {
@tivrfoa
tivrfoa / tokio-spawn-await.rs
Last active November 20, 2023 21:53
Rust tokio::spawn await
/*
$ cargo run --release --bin sp1
Finished release [optimized] target(s) in 0.09s
Running `target/release/sp1`
9227465
14930352
24157817
39088169
63245986
102334155
@tivrfoa
tivrfoa / re.rs
Last active November 2, 2023 13:37
Book Beautiful Code - A Regular Expression Matcher
/*
After reading the description:
Character Meaning
c Matches any literal character c.
. (period) Matches any single character.
^ Matches the beginning of the input string.
$ Matches the end of the input string.
* Matches zero or more occurrences of the previous character.
@tivrfoa
tivrfoa / LinkedListBenchmark.java
Created October 12, 2023 21:39
Java LinkedList vs ArrayDeque vs ArrayList
/*
Benchmark Mode Cnt Score Error Units
LinkedListBenchmark.arrayDeque avgt 6 86861,575 ± 6681,783 ns/op
LinkedListBenchmark.arrayList avgt 6 207511,921 ± 20828,824 ns/op
LinkedListBenchmark.linkedList avgt 6 70281,152 ± 9929,807 ns/op
mvn clean verify
java -jar target/benchmarks.jar LinkedListBenchmark
@tivrfoa
tivrfoa / pom.xml
Created June 28, 2023 22:53
Trying to use GraalVM to compile https://github.com/ebarlas/game-of-life-csp #Java #AWT
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>loomtest</groupId>
<artifactId>csp-game-of-life</artifactId>
<packaging>jar</packaging>
<name>CSP Game of Life</name>
<version>1.0.0-SNAPSHOT</version>
@tivrfoa
tivrfoa / BenchmarkFileRead.java
Created March 19, 2023 19:50
Java FileInputStream vs Files.lines
/*
I was reading "Modern file input/output with Java Path API and Files helper methods"
https://blogs.oracle.com/javamagazine/post/path-files-input-output
... and the author compared the C-style to read a file against the
modern Java way using streams with `Files.lines`, filter, ...
I benchmarked them using JMH and the difference is huge ...
If you think I did something wrong here, then please comment in this gist. Thank you.
@tivrfoa
tivrfoa / asterisk_location.c
Created March 19, 2023 15:51
C Pointer Asterisk Location
#include <stdio.h>
/*
asteric-location.c:7:22: warning: initialization of ‘int’ from ‘int *’ makes integer from pointer without a cast [-Wint-conversion]
7 | int* b = &a, c = &a;
| ^
*/
// void bad_placement() {
// int a = 1;
// int* b = &a, c = &a;