Skip to content

Instantly share code, notes, and snippets.

View ejpcmac's full-sized avatar
🎯
Focusing

Jean-Philippe Cugnet ejpcmac

🎯
Focusing
View GitHub Profile
@ejpcmac
ejpcmac / .gitsetup
Created October 7, 2022 18:55
Script to configure git-flow with custom values
#!/bin/sh
set -e
set -x
# Setup git-flow
git flow init -d
git config gitflow.prefix.versiontag "v"
git config gitflow.feature.finish.no-ff true
git config gitflow.release.finish.sign true
@ejpcmac
ejpcmac / build.rs
Last active September 29, 2022 20:02
Define a VERSION_WITH_GIT environment variable for Rust projects.
use std::{io, process::Command};
fn main() {
define_version_with_git();
}
/// Defines a variable containing the version with the Git revision.
///
/// `VERSION_WITH_GIT` contains at least the cargo version, even when Git is not
/// available. When Git is available, the current Git revision and dirty state
@ejpcmac
ejpcmac / zfs-clean-snapshot
Last active February 19, 2023 13:45
Clean old ZFS auto-snapshots on backup destinations
#!/bin/sh
filter_snapshots() {
echo "$1" | grep $2 | tac | tail -n +$(($3 + 1)) | sed 's/.*@//' | sed -z 's/\n/,/g'
}
if [ $# -ne 6 ]; then
echo "usage: $0 <dataset> <frequent> <hourly> <daily> <weekly> <monthly>"
exit 1
fi
@ejpcmac
ejpcmac / Procedures.md
Last active January 19, 2024 13:30
Procedures for getting back on a project and making a new release

Procedures

Getting back on a project

  • Check that the Git configuration is up to date (in Magit)
  • Checkout the develop branch (if using git-flow)
  • Bump the version to the next -dev one and reate an [Unreleased] section in the CHANGELOG.md
  • Rename the master branch to main
  • Update the CONTRIBUTING.md and README.md if necessary
@ejpcmac
ejpcmac / .envrc
Created September 28, 2018 20:55
.envrc for Phoenix projects using Nix and PostgreSQL
####################################
# Environment setup for Nix shells #
####################################
# From https://github.com/direnv/direnv/wiki/Nix#persistent-cached-shell
#
# Usage: use_nix [...]
#
# Load environment variables from `nix-shell`.
# If you have a `default.nix` or `shell.nix` one of these will be used and
@ejpcmac
ejpcmac / setup
Created September 28, 2018 20:39
Setup script for Phoenix projects using Nix and PostgreSQL
#!/bin/sh
echo
if [ ! -d "deps" ] || [ ! "$(ls -A deps)" ]; then
printf "\e[32m=> Fetching dependencies and building the application...\e[0m\n\n"
echo "+ mix do deps.get, compile --verbose"
mix do deps.get, compile --verbose
echo
fi
@ejpcmac
ejpcmac / shell.nix
Created September 28, 2018 12:14
Shell for Phoenix projects with node.js and PostgreSQL
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
inherit (lib) optional optionals;
elixir = beam.packages.erlangR21.elixir_1_7;
nodejs = nodejs-10_x;
postgresql = postgresql100;
@ejpcmac
ejpcmac / shell.nix
Last active September 26, 2018 21:08
Shell for Nerves projects
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
inherit (lib) optional optionals;
elixir = beam.packages.erlangR21.elixir_1_7;
in
mkShell {
@ejpcmac
ejpcmac / shell.nix
Last active September 26, 2018 20:48
Shell for standard Elixir projects with file_system and ExUnit Notifier
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
inherit (lib) optional optionals;
elixir = beam.packages.erlangR21.elixir_1_7;
in
mkShell {
@ejpcmac
ejpcmac / shell.nix
Created September 26, 2018 20:29
Bare minimum shell for Elixir projects
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
# I like to define variables for derivations that have
# a specific version and are subject to change over time.
elixir = beam.packages.erlangR21.elixir_1_7;
in