Skip to content

Instantly share code, notes, and snippets.

View paullaffitte's full-sized avatar

Paul Laffitte paullaffitte

View GitHub Profile
@paullaffitte
paullaffitte / install-csfml.sh
Last active June 4, 2023 08:46
CSFML installer for Ubuntu
#!/usr/bin/env bash
set -e
SFML_VERSION='2.2'
GLEW_VERSION='1.10.0'
get_file()
{
local file_to_get="$1"
@paullaffitte
paullaffitte / epochDigest.php
Last active October 11, 2017 08:38
here is the way we compute digests and compare them with the digests compted by Epoch
<?php
public function getDigest($flexpost, $source_encoding=null) {
if ( array_key_exists('epoch_digest', $flexpost) )
unset($flexpost['epoch_digest']);
ksort($flexpost);
$sorted_string = urldecode(strtr(http_build_query($flexpost), ['&' => '', '=' => '']));
if ( $source_encoding )
$sorted_string = mb_convert_encoding($sorted_string, self::UTF8_ENCODING, $source_encoding);
return hash_hmac('md5', $sorted_string, $this->hmac_key);
@paullaffitte
paullaffitte / my_get_nbr_float pseudo-code
Last active October 15, 2017 11:51
How to code my get number float at Epitech (require my_get_number or atoi and my_power_rec or my_power_it or pow)
integer = my_getnbr(str)
str = str after the '.' character
decimal = my_getnbr(str)
decimal = decimal / 10^(strlen(str)) * (1 if number is strictly positive, -1 else)
number = integer + decimal
example:
[line] [values]
[1] str = '-13.04' integer = -13
[2] str = '04' integer = -13
@paullaffitte
paullaffitte / malloc debugging macro
Created February 2, 2018 18:24
debugging macro for malloc developpement
#define PRINTF(...) \
do { \
char buffer[10000]; \
sprintf(buffer, __VA_ARGS__); \
write(1, buffer, strlen(buffer)); \
} while (0);
bits 64
section .text
global rindex:function
extern strlen
extern _GLOBAL_OFFSET_TABLE_
%macro get_GOT 0
call %%getgot
@paullaffitte
paullaffitte / Compile SFML 2.5.1
Last active August 23, 2022 17:15
It takes the version as first argument, if not provided it will use 2.5.1 - Warning : Tested on Ubuntu 20.04 only, it may not work on your distribution
#!/bin/bash
set -e
VERSION=2.5.1
if [[ -n "$1" ]]; then
VERSION="$1"
fi
@paullaffitte
paullaffitte / my_getnbr.c
Last active June 2, 2018 17:46
my_getnbr
#include <stdio.h>
#define my_getnbr(str) my_getnbr_rec(str, 0, 1, 0)
long int my_getnbr_rec(const char *str, long int nbr, char sign, char began)
{
if (*str == '-' && !began)
sign *= -1;
else if (*str >= '0' && *str <= '9' && (began = (*str != '-' && *str != '+'))) {
nbr *= 10;
@paullaffitte
paullaffitte / workshop-blender.md
Last active June 24, 2018 23:33
Workshop Blender

An introduction to blender

According to wikipedia, Blender is a professional, free and open-source 3D computer graphics software toolset used for creating animated films, visual effects, art, 3D printed models, interactive 3D applications and video games. Today we will try to modelize some basic objects and familiarize with the software.

A table for three please !

Your objective is to try to modelize a table with some chairs around. You can check the modeling section of the Blender documentation, you can ask questions as well. If you finish ealier than the other, you can even try to apply some texture to your model, maybe even some materials !

Shortcuts cheetsheet

Shortcuts in blender are pretty powerfuls, you can easily combine several of them to improve your workflow.

@paullaffitte
paullaffitte / limiter.sh
Last active October 13, 2018 20:35
Script execution limiter
#! /usr/bin/env bash
name=$1
interval=$(echo "$2" | bc)
file=~/.limiter/"$name"
now=$(date +"%s")
if [ ! -f "$file" ] || (( $(echo $now - $(cat "$file") | bc) >= $interval )); then
mkdir -p ~/.limiter
echo $now > "$file"
@paullaffitte
paullaffitte / gitpushallmaster.sh
Last active January 19, 2019 20:48
An alias to push master on all remotes
# could have been: git push '*' master
alias gitpushallmaster="for remote in \$(git remote); do echo \$remote; git push \$remote master; done"