Skip to content

Instantly share code, notes, and snippets.

@shadowhand
shadowhand / git-switchbranch
Created October 23, 2012 16:50
Fast git branch switcher
#!/bin/bash
usage() {
echo "usage: git switchbranch"
}
version() {
echo "switchbranch v0.0.2"
}
<?php
function array_key_first(array $arr)
{
reset($arr);
return key($arr);
}
function array_key_last(array $arr)
{
@shadowhand
shadowhand / NamedDTO.php
Created December 10, 2016 02:59
Using named constructors for data transfer objects
<?php
namespace Acme;
class DataTransfer
{
public static function forUser(
$user_id
) {
return new static($user_id);
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
" force utf-8 mode
scriptencoding utf-8
" i got 99 problems, but utf-8...
set encoding=utf-8
" https://github.com/junegunn/vim-plug
call plug#begin('~/.vim/plugged')
Plug 'airblade/vim-gitgutter'
@shadowhand
shadowhand / keybase.md
Last active May 26, 2018 17:11
keybase.md

Keybase proof

I hereby claim:

  • I am shadowhand on github.
  • I am shadowhand (https://keybase.io/shadowhand) on keybase.
  • I have a public key whose fingerprint is 40AF B4CD AB73 94B4 67DF E1E4 25A1 4BF1 4DEB 29D1

To claim this, I am signing this object:

<?php
declare(strict_types=1);
namespace Acme\Domain\Type;
use function Assert\that;
class EmailAddress
{
/** @var string */
@shadowhand
shadowhand / # php - 2018-04-04_13-56-32.txt
Created April 4, 2018 19:05
php on macOS 10.13.3 - Homebrew build logs
Homebrew build logs for php on macOS 10.13.3
Build date: 2018-04-04 13:56:32
@shadowhand
shadowhand / array_chunk_fixed.php
Created May 25, 2017 03:01
Array chunking for SplFixedArray
<?php
// Copyright (c) 2017 Woody Gilk (@shadowhand)
// MIT License
/**
* A chunking function for SplFixedArray
*
* Operates the same as array_chunk() but without $preserve_keys, for obvious reasons.
*
@shadowhand
shadowhand / mysql_install_db.log
Created October 23, 2014 20:39
MariaDB falling apart with corrupt mysql.proc table
Installing MariaDB/MySQL system tables in '/usr/local/var/mysql' ...
141023 15:38:30 [Note] InnoDB: Using mutexes to ref count buffer pool pages
141023 15:38:30 [Note] InnoDB: The InnoDB memory heap is disabled
141023 15:38:30 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
141023 15:38:30 [Note] InnoDB: Memory barrier is not used
141023 15:38:30 [Note] InnoDB: Compressed tables use zlib 1.2.5
141023 15:38:30 [Note] InnoDB: Using CPU crc32 instructions
141023 15:38:30 [Note] InnoDB: Initializing buffer pool, size = 128.0M
141023 15:38:30 [Note] InnoDB: Completed initialization of buffer pool
141023 15:38:30 [Note] InnoDB: Highest supported file format is Barracuda.