Skip to content

Instantly share code, notes, and snippets.

View Kerollmops's full-sized avatar
🍼
Meilisearch needs care

Clément Renault Kerollmops

🍼
Meilisearch needs care
View GitHub Profile
@Kerollmops
Kerollmops / index-stats.rs
Created June 21, 2023 14:16
A small program that computes the stats of an LMDB Meilisearch index.
//! A small program that computes the stats of an LMDB Meilisearch index.
//!
//! ```cargo
//! [dependencies]
//! anyhow = "1.0.71"
//! clap = { version = "4.3.5", features = ["derive"] }
//! heed = "0.20.0-alpha.1"
//! ```
use std::path::PathBuf;
@Kerollmops
Kerollmops / valid_I_25.fillit.md
Last active March 19, 2021 17:36
Fillit timings experiments - AMD EPYC 7401P 24- (4) @ 1.996GHz

Julow - 140h+

Never finished...

Rust - 140h+

Never finished...

Rust #2 - 281m34.146s

@Kerollmops
Kerollmops / export-imdb-sqlite.md
Last active January 23, 2023 16:15
Export a nd-JSON/JSON stream from the multiple IMDB TSVs
@Kerollmops
Kerollmops / rsync-ssh.sh
Created March 19, 2020 10:14
Remote sync a cargo repository by using fswatch and ssh with a custom identity key.
fswatch --exclude '.git' --exclude 'target' . | while read num; do
rsync -azP --exclude=.git --exclude=target -e 'ssh -i ~/.ssh/id_rsa' . root@xxx.xxx.xxx.xxx:<DEST>
done
@Kerollmops
Kerollmops / iter_kit.rs
Last active January 6, 2020 17:43
A kit of simple adapter Iterators for tricky situations (no external library needed)
/// An adapter function that returns an iterator associated
/// to a boolean indicating if this is the first item returned.
///
/// https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7ea95cd91a26de21c680ad7de8669c8d
///
/// ```
/// let words = ["Hello", "world", "!"];
/// let mut iter = is_first(&words);
///
/// assert_eq!(iter.next(), Some((true, "Hello")));
@Kerollmops
Kerollmops / cor.rs
Last active December 2, 2019 22:08
Clone on Resize - An alternative to the Cow type, keep a mutable slice until you really need to grow or shrink it.
pub enum Cor<'a, T: 'a> {
Borrowed(&'a mut [T]),
Owned(Vec<T>),
}
impl<T: Clone> Cor<'_, T> {
pub fn as_resizable(&mut self) -> &mut Vec<T> {
match self {
Cor::Borrowed(slice) => {
*self = Cor::Owned(slice.to_vec());
@Kerollmops
Kerollmops / user-typing.lua
Last active November 26, 2019 20:54
wrk script that simulate user typing queries
full_query = "I love paris and new york with my friends "
length = 1
local char_to_hex = function(c)
return string.format("%%%02X", string.byte(c))
end
local function urlencode(url)
if url == nil then
return
@Kerollmops
Kerollmops / zerocopy-lmdb.rs
Last active October 4, 2019 08:13
This little bit of code could makes the lmdb usage really easy and fast
use std::{io, marker, str};
use std::borrow::Cow;
use zerocopy::{LayoutVerified, AsBytes, FromBytes};
use serde::{Serialize, Deserialize, de::DeserializeOwned};
// Do not forget to patch zerocopy to make it support str
// by using the `trivial_bounds` feature
pub trait EPAsBytes {
fn as_bytes(&self) -> Cow<[u8]>;
@Kerollmops
Kerollmops / easy-memlog.sh
Created September 16, 2019 20:01
Record %CPU and RSS
#!/bin/bash
while true; do
ps -p $1 -o\%cpu,rss | awk 'NR>1 { gsub(",",".",$1); print $1","$2}'
sleep 0.2
done
@Kerollmops
Kerollmops / memlog.sh
Last active July 24, 2021 12:55
Record memory usage of a process
#!/usr/bin/env bash
# usage: memlog.sh $(pidof PROCESS_NAME) [ PATH_FOLDER ]
# on osx pidof can be replaced by pgrep
# usage: memlog.sh $(pgrep PROCESS_NAME) [ PATH_FOLDER ]
set -e
PID=$1