Skip to content

Instantly share code, notes, and snippets.

View zommiommy's full-sized avatar
💤
Too tired to live

Tommaso Fontana zommiommy

💤
Too tired to live
View GitHub Profile
@zommiommy
zommiommy / data.csv
Last active March 20, 2024 13:37
Bisect the stack needed to sort a vec of a given size using rayon par sort unstable
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
#![no_std]
extern crate alloc;
use alloc::vec::Vec;
use primitive::Primitive;
/// Implementation of:
/// > An Efficient Representation for Sparse Sets
/// > by Preston Briggs and Linda Torczon
/// > <https://dl.acm.org/doi/pdf/10.1145/176454.176484>
/// > <https://research.swtch.com/sparse>
@zommiommy
zommiommy / sip.rs
Created July 28, 2023 10:51
Hashes impl
//! Implementation of SipHash from [Jean-Philippe Aumasson](https://www.aumasson.jp/) and Daniel J. Bernstein.
//!
//! SipHash is a general-purpose hashing function: it runs at a good
//! speed (competitive with Spooky and City) and permits strong _keyed_
//! hashing. This lets you key your hash tables from a strong RNG, such as
//! [`rand::os::OsRng`](https://docs.rs/rand/latest/rand/rngs/struct.OsRng.html).
//!
//! Although the SipHash algorithm is considered to be generally strong,
//! it is not intended for cryptographic purposes. As such, all
//! cryptographic uses of this implementation are _strongly discouraged
@zommiommy
zommiommy / main.rs
Created May 28, 2023 19:57
Implementation of online first and second order ordinary least squares regression
/// A simple online linear regression algorithm.
/// See https://en.wikipedia.org/wiki/Simple_linear_regression#Fitting_the_regression_line
/// for details.
pub struct FirstOrderOLS {
x: f64,
y: f64,
xx: f64,
xy: f64,
n: usize,
@zommiommy
zommiommy / bench.rs
Created May 12, 2023 15:28
Code for benchmarking all the implementations of the cardinality extimations of hyperloglog
#![feature(test)]
extern crate test;
use test::{black_box, Bencher};
// Optionally include some setup
const NUMBER_OF_ELEMENTS: usize = 10_000;
const BITS: usize = 5;
fn gen_data() -> Vec<u8> {
let mut res = Vec::with_capacity(NUMBER_OF_ELEMENTS);
@zommiommy
zommiommy / lib.rs
Last active January 14, 2023 18:43
Better num-traits ?
#![deny(unconditional_recursion)]
use core::fmt::{Debug, Display, LowerHex, Binary};
use core::ops::*;
use core::sync::atomic::*;
use core::num::*;
/// Trait of operations possible on both Signed and Unsiged words
pub trait Number: Sized + Send + Sync +
Display + LowerHex +
@zommiommy
zommiommy / .env
Created October 4, 2022 15:41
Elastic + Kibana + TheHive + Cortex
# Version of Elastic products
STACK_VERSION=8.4.2
# Port to expose Elasticsearch HTTP API to the host
ES_PORT=9200
# Port to expose Kibana to the host
KIBANA_PORT=5601
# RAM for each service 4GB
@zommiommy
zommiommy / emulator.py
Last active September 26, 2022 21:27
iki1vm-crackmeeva aka armando che mi fa' perdere tempo https://github.com/TeamItaly/TeamItalyCTF-2022/tree/master/CrackmeEVA
import struct
def u32(data):
return struct.unpack("i", data)[0]
def p32(data):
return struct.pack("i", data)
class Regs:
IP = 0
@zommiommy
zommiommy / main.py
Last active May 31, 2022 14:20
Manual Logistic Regression with SGD, Momentum, Adam, Nadam
import time
import numpy as np
from tqdm.auto import trange
import matplotlib.pyplot as plt
from optimizers import SGD, Momentum, Adam, Nadam
# Generate some data
positives = np.random.normal(loc=-0.3, size=1000)
negatives = np.random.normal(loc=0.0, size=1000)
@zommiommy
zommiommy / bench.rs
Last active January 23, 2022 10:29
Benching of AVX dish vs relu
#![feature(portable_simd)]
#![feature(test)]
extern crate test;
use test::{black_box, Bencher};
use std::convert::TryInto;
use std::simd::*;
use std::arch::x86_64::*;
type Reg = f32x8;