Skip to content

Instantly share code, notes, and snippets.

View glapa-grossklag's full-sized avatar

Miles Glapa-Grossklag glapa-grossklag

View GitHub Profile
#!/bin/sh
# Search recursively for all files with the extension of the first argument.
# Replace them with the extension of the second argument.
if [ "$#" -ne 2 ]; then
echo "Usage:"
echo " $0 <from> <to>"
exit 1
fi
@glapa-grossklag
glapa-grossklag / debug.h
Last active July 3, 2021 05:18
Some C debug macros
/*
* A collection of three macros for debugging: DEBUG, WARN, ERROR.
*
* All three take a variable number of arguments and match the format of the
* printf family of functions. For example:
* WARN("The value of n is %d\n", n);
*
* All three are disabled if NDEBUG is defined, just like assert.
*
* by Miles Glapa-Grossklag, 2021
@glapa-grossklag
glapa-grossklag / pomodoro.sh
Created August 10, 2021 01:08
A simple shell script pomodoro timer
#!/bin/sh
# A simple pomodoro timer. Uses an interval of 25 minutes on, 5 minutes off by
# default, but is configurable using optional arguments.
#
# Usage:
# ./pomodoro.sh [on time] [off time]
#
# Example (using an interval of 30 min on, 10 min off):
# ./pomodoro.sh 30 10
@glapa-grossklag
glapa-grossklag / gmp_factorial.c
Created November 13, 2021 01:06
GMP Factorial
#include <gmp.h>
#include <stdio.h>
#include <stdlib.h>
/**
* Compute the factorial of `n` and store it in `f`.
*/
void factorial(mpz_t f, mpz_t n) {
// f ← 1
mpz_set_ui(f, 1);