Skip to content

Instantly share code, notes, and snippets.

View Pierstoval's full-sized avatar
🌖

Alex Rock Pierstoval

🌖
View GitHub Profile
@Pierstoval
Pierstoval / imagemagick_geometry.php
Last active January 9, 2020 15:24
This enormous regexp matches any "Geometry" parameter for ImageMagick. See the docs about this: http://www.imagemagick.org/script/command-line-processing.php#geometry
<?php
$number = "\d*(?:\.\d+)?"; // It's a reference to use in other cases that matches any kind of number/float
$width = "(?<w>(?:$number)?%?)?"; // This is the first part, the width
$height = "(?:x(?<h>(?:$number)?%?))?"; // Here is the height, the same as "width" but starting with an "x"
$aspect = "[!><@^]"; // These are the different filters one can use to stretch, shrink, etc.
$size = "$width$height"; // To match any size we need width and height at least (aspect comes later)
@Pierstoval
Pierstoval / pre-receive.bash
Last active September 9, 2021 07:46
Git pre-receive example to use a bare repo to deploy an ap
#!/bin/bash
########################################################################
################################ README ################################
########################################################################
#
# This script is here to allow the use of "git push prod v1.2.3" commands or similar.
#
# Push a tag to a bare repository having this file as pre-receive hook,
# and you'll be able to deploy directly from command line in your local environment,
@Pierstoval
Pierstoval / git-squash
Last active August 29, 2015 14:19
Git squash extension. Put this file on /usr/local/share/git-squash/git-squash on most unix distribs
#!/bin/bash
# Author: Joel Nothman
# Optimized by Pierstoval
# Under BSD-2 license
# See https://github.com/jnothman/git-squash
# See https://github.com/Pierstoval/git-squash
usage() {
echo ""
echo Usage: git squash '[-m <commit msg>] [-a|--append] [-f|--full] <base>'