Skip to content

Instantly share code, notes, and snippets.

View rbobillot's full-sized avatar

Raphael Bobillot rbobillot

View GitHub Profile
@rbobillot
rbobillot / ft_atoi.c
Created March 27, 2024 05:13
A quite functional implementation of the atoi function in C
int is_digit(const char c) {
return c >= '0' && c <= '9';
}
int is_space(const char c) {
return c >= 8 && c <= 32;
}
const char *tr_trimhead(const char *s) {
return s && is_space(*s) ? tr_trimhead(s+1) : s;
@rbobillot
rbobillot / nerd-fronts-DroidSansMNerdFont-Regular-b64
Last active November 13, 2023 23:59
Perfect Nerd Font for LazyVim
This file has been truncated, but you can view the full file.
T1RUTwALAIAAAwAwQ0ZGIKXsRL0AACcYAECCu0dERUYAJyfwAECp1AAAAB5PUy8yoZaXbAAAASAA
AABgUGZFZBbk10MAQKn0AAACOGNtYXDQlLSxAAAJVAAAHaJoZWFkCfegMwAAALwAAAA2aGhlYQ/d
/hQAAAD0AAAAJGhtdHglghiQAECsLAAAT9htYXhwJ+pQAAAAARgAAAAGbmFtZTcsziYAAAGAAAAH
0XBvc3T/aQBnAAAm+AAAACAAAQAAAAEAALQ1QetfDzz1AAsIAAAAAADBx+lUAAAAAOCia5v+yP3V
CaYIcgAAAAgAAgAAAAAAAAABAAAHbf4dAAAEzf7I+ycJpgABAAAAAAAAAAAAAAAAAAAAAgAAUAAn
6gAAAAQEzQGQAAUACAWaBTMAAAEeBZoFMwAAA9AAZgHyAAACCwYJAwgEAgIE4AAC70AAIFsAAAAo
AAAAADFBU0MBwAAg//8Hbf4dAAAHbQHjIAABnwAAAAAESgW2ACAAIAABAAAAHAFWAAEAAAAAAAAA
NABqAAEAAAAAAAEAFADJAAEAAAAAAAIABwDuAAEAAAAAAAMAGgEsAAEAAAAAAAQAFAFxAAEAAAAA
AAUAJwHWAAEAAAAAAAYADAIYAAEAAAAAAAcATgLDAAEAAAAAAAgAFAM8AAEAAAAAAAoAZwQhAAEA
AAAAAAsAHATDAAEAAAAAAAwALgU+AAEAAAAAAA0ALgXLAAEAAAAAAA4AKgZQAAMAAQQJAAAAaAAA
@rbobillot
rbobillot / prompt_show_branch.bash
Last active October 23, 2023 20:03
Simple Bash tool, displaying current branch, in the current Git repository
#!/bin/bash
export SHOW_BRANCH=yes
function git_working_status {
if [[ `git status 2> /dev/null` != "" && `echo $SHOW_BRANCH` == "yes" ]]
then
current_branch=`LANG=en_US.UTF-8 LANGUAGE=en_US:en git status 2> /dev/null | head -1 | cut -d ' ' -f3`
current_unt_status=`LANG=en_US.UTF-8 LANGUAGE=en_US:en git status | egrep -i "untracked files|changes not staged"`
current_add_status=`LANG=en_US.UTF-8 LANGUAGE=en_US:en git status | egrep -i "changes to be committed"`
@rbobillot
rbobillot / solving_kryptos.py
Last active October 1, 2023 03:25
Solving KRYTPOS ciphered messages (K1, K2, K3, and one day, K4), in Python (for educational purposes)
import os
import requests # pip install requests
K = dict({
'1':
'EMUFPHZLRFAXYUSDJKZLDKRNSHGNFIVJ' +
'YQTQUXQBQVYUVLLTREVJYQTMKYRDMFD',
'2':
'VFPJUDEEHZWETZYVGWHKKQETGFQJNCE' +
'GGWHKK?DQMCPFQZDQMMIAGPFXHQRLG' +
@rbobillot
rbobillot / ListMergeSort.scala
Last active September 25, 2023 02:46
Scala 3 pure immutable recursive merge sort
object Main:
@scala.annotation.tailrec
def merge(xs: List[Int], ys: List[Int], res: List[Int] = Nil): List[Int] =
(xs, ys) match
case (x :: t, y :: s) if x < y => merge(t, ys, res ::: x :: Nil) // using List concatenation to append `x` to `res`
case (x :: t, y :: s) => merge(xs, s, res ::: y :: Nil)
case (Nil, _) => res ::: ys
case (_, Nil) => res ::: xs
@rbobillot
rbobillot / cycle_jour_nuit_pokemon_EV.csv
Last active January 30, 2023 02:55
Heures de la Nintendo Switch, correspondant au cycles jour/nuit dans les jeux Pokemon Ecarlate et Violet
jour soir nuit
00h19 00h55 00h58
01h31 02h07 02h10
02h43 03h19 03h22
03h55 04h31 04h34
05h07 05h43 05h46
06h19 06h55 06h58
07h31 08h07 08h10
08h43 09h19 09h22
09h55 10h31 10h34

Description:

Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go to the end of the queue. Then the next in the queue (Leonard) buys a can, drinks it and gets to the end of the queue as two Leonards, and so on.

For example, Penny drinks the third can of cola and the queue will look like this:

Rajesh, Howard, Sheldon, Sheldon, Leonard, Leonard, Penny, Penny Write a program that will return the name of the person who will drink the n-th cola.

Input

The input data consist of an array which contains at least 1 name, and single integer n.

@rbobillot
rbobillot / pkm_ser_de.py
Last active November 16, 2022 17:35
pkm_ser_de: Python3.10 Script to Serialize/Deserialize Gen4's .pkm files (from/to JSON), it can also edit some fields
#!/usr/bin/env python3.10
import itertools
import json
import random
import struct
import sys
import uuid
from array import array
from base64 import b64encode, b64decode
# Fixes a "no sound after sleep" bug on Ubuntu (20.04 and 22.04)
#
# After sleep (on my Mi Notebook laptop, for example),
# the sound doesn't work anymore on the main audio output (but still works through the jack cable)
# Running these commands will fix it
audio_restore() {
DEVICE_ID=`lspci -D |grep Audio|awk '{print $1}'`
sudo su - -c "echo 1 > '/sys/bus/pci/devices/${DEVICE_ID}/remove'"
object Main {
import scala.language.higherKinds
/**
* Functor contains a function
* that maps from a category to another
*/
trait Functor[F[_]] {
def map[A, B](fa: F[A])(f: A => B): F[B]