Skip to content

Instantly share code, notes, and snippets.

Rob Allen akrabat

Block or report user

Report or block akrabat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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 Mar 31, 2019
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] {
@akrabat
akrabat / .bash_profile
Last active Mar 9, 2017
Swap OpenWhisk credentials
View .bash_profile
# OpenWhisk
function owibm() {
wsk property set --apihost openwhisk.ng.bluemix.net --auth {auth key here}
wsk property unset --namespace
}
function owlocal() {
(
cd ~/Projects/openwhisk/openwhisk/tools/vagrant && \
@akrabat
akrabat / README.md
Last active Mar 7, 2017
Slim PR workflow summary
View README.md

Assumptions:

  1. You have hub (https://github.com/github/hub) installed
  2. You have your own fork of Slim as origin and have added slimphp/slim as a remote called upstream

Process:

  1. Update:

     $ git checkout 4.x && git pull upstream 4.x
    
@akrabat
akrabat / Makefile
Created Feb 11, 2017
Makefile for building rst2pdf presentations, creating a PDF and a Keynote file
View Makefile
.PHONY: all clean keynote
# name of the PDF to create
pdf = ../2017-02-22-PHPOxford-Slim-OAuth2.pdf
# Aspect ratio of Keynote file
# common choices:
# 1024 x 768
# 1280 x 720
aspect_ratio = 1280 x 720
@akrabat
akrabat / test.php
Created Dec 7, 2016
Playing with code
View test.php
<?php
class CustomerMaintenanceControllerFactory
{
public function __invoke($c) {
$customerMapper = $c->get('CustomerMapper');
$deleteForm = $c->get('CustomerDeleteForm');
$editForm = $c->get('CustomerEditForm');
return new CustomerMaintenanceController($customerMapper, $deleteForm, $editForm);
}
@akrabat
akrabat / test.php
Created Dec 6, 2016
Using ControllerPluginManager factories to inject dependencies into a controller in ZF2 and ZF3
View test.php
<?php
// Using ControllerPluginManager factories to inject dependencies into
// a controller in ZF2 and ZF3
namespace My;
use Zend\Mvc\Controller\PluginManager as ControllerPluginManager;
class BookControllerFactory {
public function __invoke($container) {
// in ZF2, $container is an instance of ControllerPluginManager
You can’t perform that action at this time.