Skip to content

Instantly share code, notes, and snippets.

[alias]
recent="!myf() { git for-each-ref --sort=-committerdate refs/heads/ --format='%(HEAD) %(color:red)%(objectname:short)%(color:reset)|%(color:blue)%(authorname)%(color:reset)|%(color:bold green)%(committerdate:relative)%(color:reset)|%(color:yellow)%(refname:short)%(color:reset)|%(contents:subject)' --color=always --count=20 | column -ts '|';}; myf"
logline="!myf2() { git -P log -15 --graph --pretty=format:'%Cred%h%Creset - %Cblue%an%Creset %C(bold green) %cr %Creset %s %C(yellow)%d%Creset' --abbrev-commit; }; myf2"
@RWhar
RWhar / signedS3Links.php
Last active August 29, 2015 14:17
Signed S3 Links
@RWhar
RWhar / sesSwiftMail.php
Last active August 29, 2015 14:17
Send email with Swift & SES
<?php
/**
* Requires
* "swiftmailer/swiftmailer": "5.*"
* "aws/aws-sdk-php": "2.7.25"
*/
use Aws\Common\Credentials\Credentials;
use Aws\Ses\SesClient;
@RWhar
RWhar / nonConcurrentScript.php
Last active December 11, 2023 07:01
Prevent concurrent execution of PHP Script
/**
* Creates an exclusive lock
* @param $lockDir Directory to create/access lock file
* @param $lockName Name for lock
* @param $lockHandle Reference to scope var to maintain file handle after lock call completes
* @return bool
* @throws Exception on $lockdir not writable, unable to create file handle, unable to obtain ex_lock
*/
function lock($lockDir, $lockName, &$lockHandle)
{
@RWhar
RWhar / PHPUnitMockMagicGet
Last active July 26, 2022 06:16
PHPUnit - Mock _get() on an Abstract Class
class TestMyObjectLoader extends PHPUnit_Framework_TestCase
{
protected $mockObject;
public function setUp()
{
$this->mockObject = $this->getMockForAbstractClass('Project\MyObject', [], '', true, true, true, ['initialize', '__get']);
}