Skip to content

Instantly share code, notes, and snippets.

View plaffitt's full-sized avatar

Paul Laffitte plaffitt

View GitHub Profile
@plaffitt
plaffitt / constframerate.sh
Last active August 15, 2019 11:45
Convert movies to constant framerate with FFmpeg reading filenames on stdin
#! /usr/bin/env bash
dest=$1
fps=$2
if [[ -z "$dest" ]]; then
dest='.'
fi
if [[ -z "$fps" ]]; then
fps=60
@plaffitt
plaffitt / Chat.sh
Last active May 23, 2019 18:38
A filesystem based chat written exclusively in bash
#!/usr/bin/env bash
# Author: Paul Laffitte
# Description: A filesystem based chat written exclusively in bash
# Dependency (the only one): https://github.com/clibs/entr
if [ "$1" == '--server' ]; then
touch chat.log chat.message
ls chat.message | entr bash -c 'cat chat.message && cat chat.message >> chat.log'
else
@plaffitt
plaffitt / 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"
@plaffitt
plaffitt / 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"
@plaffitt
plaffitt / 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.

@plaffitt
plaffitt / 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;
@plaffitt
plaffitt / 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
bits 64
section .text
global rindex:function
extern strlen
extern _GLOBAL_OFFSET_TABLE_
%macro get_GOT 0
call %%getgot
@plaffitt
plaffitt / 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);
@plaffitt
plaffitt / 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