Skip to content

Instantly share code, notes, and snippets.

@chrplr
chrplr / pretty_du
Created November 3, 2019 09:56
pretty print the output of `du | sort -rn`
#! /usr/bin/env python3
# Time-stamp: <2019-11-03 10:53:53 christophe@pallier.org>
""" Cleanly format the output of ``du``.
Example:
du Documents/ | sort -rn | pretty_du | head
@chrplr
chrplr / playwav_withsdl2.c
Created May 26, 2021 13:03
playing a single sound file (wav) with SDL2
/* Play a sound file (wav format) passed on the command line, using libsdl2
*
* Time-stamp: <2021-05-26 14:58:39 christophe@pallier.org>
*
* Compile with:
* cc -W -Wall $(sdl2-config --cflags) test_playsound.c $(sdl2-config --libs) -o test_playsound
*/
#include <stdio.h>
#include <SDL2/SDL.h>
@chrplr
chrplr / tokenize.c
Last active July 2, 2021 09:09
tokenize text in C
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
const char* DELIMITERS = "!\"#$%&'()*+,-./:;<=>?@[]^_`{|}~\\\t\n\r ";
int main(int argc, char* argv[])
{
FILE* fd;
@chrplr
chrplr / setup-psych-expe-generators.md
Last active June 20, 2022 08:26
psychology-stimulation-software-on-linux

Installing a Linux workstation with psychtoolbox, psychopy, expyriment

Author: christophe@pallier.org

Date: 05 Nov 2021

Warning: These instructions work for Ubuntu 20.04 LTS focal (will probalby need some modifications for another Ubuntu distribution)

Install some basic packages

@chrplr
chrplr / pyenv-for-expyriment.md
Last active March 27, 2023 10:35
installing expyriment in a python virtual environment (Ubuntu 22.04)

expyriment is a great Python library to program psychology experiments.

However pip install expyriment fails with many versions of Python because it tries to recompile pygame

Here we show how to use pyenv to create an environement with Python 3.7.6 in which "pip install expyriment" should work.

Installation

sudo apt install -y python3-pip python-is-python3 python3.10-venv
@chrplr
chrplr / pyenv_install_ubuntu22.04.md
Created May 21, 2024 06:16
pyenv installation under ubuntu 22.04

pyenv install under ubuntu 22.04

sudo apt install curl libssl-dev liblzma-dev libbz2-dev libsqlite3-dev libffi-dev tk-dev
curl https://pyenv.run | bash

cat >> ~/.bashrc <<EOF
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

eval "$(pyenv virtualenv-init -)"