Skip to content

Instantly share code, notes, and snippets.

Rob Allen akrabat

View GitHub Profile
@akrabat
akrabat / Vagrantfile
Last active Jun 26, 2020
Vagrantfile starting point for PHP/MySQLn
View Vagrantfile
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 Jun 20, 2020
Dockerfile for rst2pdf testing
View Dockerfile
# 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]
View KeywordAlbum.applescript
--
-- 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 / snippets.lua
Last active Dec 28, 2019
Useful Lua snippets
View snippets.lua
--[[
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'
@akrabat
akrabat / Vagrantfile
Last active Mar 23, 2020
Example Vagrantfile for Windows
View Vagrantfile
# -*- 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 / vimdc
Created Jan 19, 2019
Basic vim setup ~/.vim/vimrc
View vimdc
set nocompatible
" General settings
syntax on
filetype plugin indent on
set autoread " Automatically reload changed files
set autowrite " Automatically save before :next, :make etc.
set backspace=indent,eol,start " backspace from this line to the previous one
set encoding=utf-8 " UTF-8 is good…
@akrabat
akrabat / shell.sh
Last active Dec 15, 2017
Binding an ElephantSQL's credentials to a Bluemix OpenWhisk action
View shell.sh
# A simple action to prove it works
$ cat myaction.php
<?php
function main(array $args) : array
{
return $args;
}
$ bx wsk action update myaction myaction.php
# Create the PostgreSQL database
@akrabat
akrabat / ctags
Last active Apr 13, 2020
git hooks for ctags. Place in `.git_template/hooks/` & run: `git config --global init.templatedir '~/.git_template'`
View ctags
#!/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 / CorsMiddlewareFactory.php
Created Oct 21, 2017
Expressive factory to use CORS middleware
View CorsMiddlewareFactory.php
<?php declare(strict_types=1);
namespace App\Factory;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Tuupola\Middleware\Cors;
use Zend\Diactoros\Response;
use Zend\Diactoros\Response\JsonResponse;
use Zend\ProblemDetails\ProblemDetailsResponseFactory;
use Zend\Stratigility\Middleware\CallableMiddlewareWrapper;
@akrabat
akrabat / rock-paper-scissors.swift
Created Sep 13, 2017
OpenWhisk Rock-Paper-Scissors game
View rock-paper-scissors.swift
// Rock Paper Scissors game
// To install:
// $ wsk action update rock-paper-scissors rock-paper-scissors.swift
//
// To play:
// $ wsk action invoke rock-paper-scissors -r -p shape rock
import Foundation
func main(args: [String:Any]) -> [String:Any] {
You can’t perform that action at this time.