Skip to content

Instantly share code, notes, and snippets.

View lorenzofelletti's full-sized avatar

Lorenzo Felletti lorenzofelletti

View GitHub Profile
@tdelabro
tdelabro / no_std-guide.md
Last active June 14, 2024 02:58
How to easely port a crate to `no_std`?

What is Rust's standard library?

One of the Rust programming language promises is "zero-cost abstraction". Therefore the language itself is pretty conservative about what it incorporates. Types that are basics in other languages, such as string, or features, such as async, cannot be part of the language itself because they are costly abstractions. The user may not need them at all, or he may prefer other alternative implementations. To make those types and functions available nonetheless, they are available as part of the Rust standard library, known as std. Part of this library, known as the prelude is imported by default in each .rs file so you don't have to repeat yourself too much.

Why would you want a no_std version of your crate?

Most of the time having this standard library available is not a problem because you run your code on a pretty standard environment: your own computer or a Linux server somewhere in the cloud. However, somet

@gdsotirov
gdsotirov / check_pos_int_number.tf
Created August 19, 2020 13:30
Check a number variable in Terraform to be a positive integer
# Check whether an input variable is a positive integer in Terraform
# Tested with version 0.13
variable "release" {
type = number
description = "Release number"
default = 0
validation {
condition = tonumber(var.release) == floor(var.release)
error_message = "Release should be an integer!"
}
@sahilsk
sahilsk / kafka-cheat-sheet.md
Last active May 29, 2024 17:38 — forked from filipefigcorreia/kafka-cheat-sheet.md
Apache Kafka Cheat Sheet

Kafka Cheat Sheet

Display Topic Information

$ kafka-topics.sh --describe --zookeeper localhost:2181 --topic beacon
Topic:beacon	PartitionCount:6	ReplicationFactor:1	Configs:
	Topic: beacon	Partition: 0	Leader: 1	Replicas: 1	Isr: 1
	Topic: beacon	Partition: 1	Leader: 1	Replicas: 1	Isr: 1
[app]
# (str) Title of your application
title = Kpritz
# (str) Package name
package.name = Kpritz
# (str) Package domain (needed for android/ios packaging)
package.domain = fr.tshirtman.kpritz
@earthgecko
earthgecko / bash.generate.random.alphanumeric.string.sh
Last active July 4, 2024 17:31
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"