Skip to content

Instantly share code, notes, and snippets.

View akrabat's full-sized avatar

Rob Allen akrabat

View GitHub Profile
@akrabat
akrabat / no_automount
Created August 5, 2020 08:51
Add a volume to /etc/fstab to prevent auto-mounting. See http://akrabat.com/prevent-an-external-drive-from-auto-mounting-on-macos/
#!/usr/bin/env bash
# Usage: ./no_automount My\ Disk
NAME=$1
if [ -z "$NAME" ] ; then
echo "Usage: no_automount {Disk Name}"
exit 1
fi
FSTAB=/etc/fstab
--
-- For each album, add a hierarchical keyword of the format
-- "PhotosExport>folder1>folder2>album" to each photo.
--
-- Copyright 2019 Rob Allen.
-- License: MIT - https://akrabat.com/license/mit/
--
-- Variables to control how many albums to process per run
-- change appropriately per run if you need to do in batches
@akrabat
akrabat / Vagrantfile
Last active December 16, 2022 14:44
Example Vagrantfile for Windows
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Base box: https://github.com/akrabat/packer-templates
Vagrant.configure("2") do |config|
config.vm.box = "19ft/windows2016"
config.vm.guest = :windows
config.vm.boot_timeout = 600
@akrabat
akrabat / UnauthorizedStrategy.php
Created September 25, 2012 19:27
bjyAuthorise view strategy to redirect to login page on auth failure
<?php
namespace Application\View;
use BjyAuthorize\Service\Authorize;
use Zend\EventManager\EventManagerInterface;
use Zend\EventManager\ListenerAggregateInterface;
use Zend\Http\Response as HttpResponse;
use Zend\Mvc\MvcEvent;
use Zend\Stdlib\ResponseInterface as Response;
@akrabat
akrabat / ctags
Last active January 28, 2021 06:52
git hooks for ctags. Place in `.git_template/hooks/` & run: `git config --global init.templatedir '~/.git_template'`
#!/bin/sh
set -e
PATH="$HOME/bin:/usr/local/bin:$PATH"
mkdir .git/tags_lock 2>/dev/null || exit 0
trap 'rmdir .git/tags_lock; if [ -f .git/tags.$$ ]; then rm .git/tags.$$; fi' EXIT
# Assumes universal-ctags is on the path
ctags --tag-relative=yes -R -f .git/tags.$$
mv .git/tags.$$ .git/tags
@akrabat
akrabat / phplint
Last active August 13, 2020 14:53
RRecursive php lint
#!/usr/bin/env bash
set -o nounset
# Recursively call `php -l` over the specified directories/files
if [ -z "$1" ] ; then
printf 'Usage: %s <directory-or-file> ...\n' "$(basename "$0")"
exit 1
fi
@akrabat
akrabat / Vagrantfile
Last active June 26, 2020 10:06
Vagrantfile starting point for PHP/MySQLn
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/focal64"
# Shared ports
# config.vm.network "forwarded_port", host:8888, guest: 80
# config.vm.network "forwarded_port", host:3307, guest: 3306
# Mount shared folder using NFS
# config.vm.synced_folder ".", "/vagrant",
@akrabat
akrabat / Dockerfile
Created June 20, 2020 12:52
Dockerfile for rst2pdf testing
# To run:
#
# docker build -t rst2pdfdev .
# docker run --rm -v $(pwd)/rst2pdf:/rst2pdf -it rst2pdfdev bash
#
# Now, in the bash prompt:
#
# pip3 install --upgrade setuptools
# pip3 install pytest
# pip3 install -c requirements.txt -e .[tests,sphinx,images,svgsupport,aafiguresupport,mathsupport,rawhtmlsupport]
@akrabat
akrabat / slim-container-examples.php
Last active April 28, 2020 08:14
Example uses of Slim 3's container
<?php
// All file paths relative to root
chdir(dirname(__DIR__));
require "vendor/autoload.php";
$settings = ['foo' => 'FOO', 'bar' => 'BAR'];
$app = new \Slim\App($settings);
// Set some things into the container
@akrabat
akrabat / snippets.lua
Last active December 28, 2019 12:20
Useful Lua snippets
--[[
Does "str" start with "start"?
]]
local function starts_with(str, start)
return str:sub(1, #start) == start
end
--[[
Get the item with a getName() of 'name' from the table 'collection'