Skip to content

Instantly share code, notes, and snippets.

View Pierstoval's full-sized avatar
🌒

Alex Rock Pierstoval

🌒
View GitHub Profile
@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>'
@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 / keybase.md
Last active April 21, 2019 19:44
keybase.md

Keybase proof

I hereby claim:

  • I am pierstoval on github.
  • I am pierstoval (https://keybase.io/pierstoval) on keybase.
  • I have a public key ASDMqGJzpJ2OMQa9tDDwznVYnbzPVW7K4oDlKUBliBawWAo

To claim this, I am signing this object:

pierstoval@PIERSTOVAL /mnt/e/dev/www/sandbox $ ./test.bash
KO for key ALLUSERSPROFILE
KO for key APPDATA
KO for key CLINK_DIR
KO for key CommonProgramFiles
KO for key CommonProgramW6432
KO for key COMPUTERNAME
KO for key ComSpec
KO for key FPS_BROWSER_APP_PROFILE_STRING
@Pierstoval
Pierstoval / devices.php
Last active August 18, 2017 11:20
See the size of your website on most famous devices
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
* { margin: 0; padding: 0; box-sizing: border-box; }
iframe {
overflow: hidden;
border: solid 1px black;
@Pierstoval
Pierstoval / _PHP is_a() vs is_subclass_of().md
Last active September 7, 2025 00:55
`is_a()` vs `is_subclass_of()`

PHP is_a() vs is_subclass_of()

<?php

class A {}

class B extends A {}
@Pierstoval
Pierstoval / timelapse.cmd
Last active July 14, 2018 12:42
Timelapse from imges with FFMPEG and ImageMagick
REM Batch file for Windows only
REM This script takes images from a
SET EXTENSION=jpg
REM This is NOT an usual glob pattern.
REM This example matches 4 digits, like "DSC_0243".
SET PATTERN=DSC_%04d"
ffmpeg.exe -r 24 -i %PATTERN%.%EXTENSION% -s hd720 -vcodec libx264 out.mp4
// LOOOTS of stuff there: https://github.com/denysdovhan/wtfjs
// From https://www.destroyallsoftware.com/talks/wat
[] + []; // empty string
[] + {}; // [object Object]
{} + []; // 0
{} + {}; // NaN
Array(16); // ,,,,,,,,,,,,,,,, (array with 16 undefined elements)
Array(16).join('wat'); // watwatwatwatwatwatwatwatwatwatwatwatwatwatwatwat (array with 16 "wat" strings)
MYSQL_VERSION=8.0
# Check if the "mysql" container is running
number_of_running_containers=$(docker ps --filter "name=mysql" | grep -w "mysql" | wc -l)
if [ $number_of_running_containers = "1" ] ; then
echo "MySQL is already running:"
docker ps --filter "name=mysql"
echo "You can stop it by executing \"docker stop mysql\""
@Pierstoval
Pierstoval / check-requirements.Makefile
Last active July 3, 2026 10:13
"Check requirements" command for your Makefile
# Use it like this:
#
# $ printf $(_TITLE) "Something in green" "The message"
#
# This will output something like this:
#
# [Something in green] The message
#
# (of course, with proper colors)
_TITLE := "\033[32m[%s]\033[0m %s\n" # Green text