Skip to content

Instantly share code, notes, and snippets.

View saskenuba's full-sized avatar
🏠
Working from home

Martin Mariano saskenuba

🏠
Working from home
View GitHub Profile
// A different version of chapter 8-01 on futex.
//! https://github.com/m-ou-se/rust-atomics-and-locks/blob/main/examples/ch8-01-futex.rs
//!
//! This version demonstrates how we can create an anonymous
//! memory-backed file (through memfd_create syscall), map it into the
//! program's memory (through mmap, memmap2 crate) and store a futex
//! on it. The futex is awakened later after the thread resumes from sleep.
//!
//! Futexes can be useful for having a finely grained concurrency
//! control on memory.
@saskenuba
saskenuba / utils.rs
Last active May 20, 2022 16:38
Validar CPF Rust lang
/// Valida CPF
/// Espera um `&str` no formato: "52998224725"
pub fn validate_cpf(cpf: &str) -> bool {
let all_digits_repeated = [cpf.chars().nth(0).unwrap()]
.repeat(11)
.into_iter()
.collect::<String>();
if cpf.len() != 11 || cpf == &*all_digits_repeated {
return false;
@saskenuba
saskenuba / gendocs.sh
Last active January 10, 2020 17:07
Generates rust offline documentation for the desired crate, and installs it on Zeal.
#!/usr/bin/zsh -f
set -eo pipefail
IFS=$'\n\t'
# ---------------------------------------------------------------------------------------------------
# Generates docset for the desired rust crate, and installs it to work with Zeal (offline doc tool).
# Optionally accepts an image link to add an icon.
#
# Author: Martin Mariano
#
;;; packages.el --- martinmariano layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
;;
;; Author: <martin@Adam>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3