Skip to content

Instantly share code, notes, and snippets.

@matrey
matrey / update-multiple
Last active Apr 29, 2018
Multiple update hooks for Gitlab
View update-multiple
#!/bin/bash
# The standard, global, Gitlab update hook
update_true_path="$(cd `dirname $(readlink $0)` && pwd)"
update_gitlab="$update_true_path/update"
# Additional, local, update.before and update.after hooks
hooks_dir="$(cd `dirname $0` && pwd)"
update_before="$hooks_dir/update.before"
update_after="$hooks_dir/update.after"
@matrey
matrey / ltsv.php
Created Apr 29, 2018
Linear TSV encode/decode for PHP
View ltsv.php
<?php
function ltsv_decode($data){
// From parse_field (https://github.com/solidsnack/tsv/blob/master/tsv.py#L90)
$stack = [];
$replaces = ['t' => "\t", 'n' => "\n", 'r' => "\r", '\\' => "\\"];
$tmp = explode("\\", $data, 2);
while (count($tmp) >= 2){
$stack[] = $tmp[0];
@matrey
matrey / ec2-create-ubuntu-ami.sh
Created Oct 15, 2020
ec2-create-ubuntu-ami.sh
View ec2-create-ubuntu-ami.sh
#!/bin/bash
set -euo pipefail
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Thanks:
# * https://github.com/alestic/alestic-git/blob/master/bin/alestic-git-build-ami for the overall approach and ec2 commands
# * https://github.com/kickstarter/build-ubuntu-ami/blob/master/data/user_data.sh.erb for the user script run in chroot
# * https://blog.tinned-software.net/mount-raw-image-of-entire-disc/ for how to mount the raw image with losetup