Skip to content

Instantly share code, notes, and snippets.

@s7anley
s7anley / commit-file.sh
Last active May 18, 2017 15:13
Amend of history commit for forgotten file.
#!/usr/bin/env bash
$(git diff-index --quiet HEAD $1) > /dev/null
FILE_CHANGED=$?
if [ $FILE_CHANGED -eq 1 ];then
COMMIT=$(git log -n 1 --pretty=format:%H -- $1)
git add $1
git commit --fixup=$COMMIT
git rebase --interactive --autosquash $COMMIT^
fi
@s7anley
s7anley / test_setup_and_teardown.py
Last active March 28, 2017 03:19
Reusable setup and teardown for pytest
import pytest
def populate_tables(tables):
pass
def truncate_tables(tables):
pass

Keybase proof

I hereby claim:

  • I am s7anley on github.
  • I am s7anley (https://keybase.io/s7anley) on keybase.
  • I have a public key ASC4tQjNQ_pwK0zrQJQbuvmOEoSTs20Qaoo3xNjkQIqoEgo

To claim this, I am signing this object:

@s7anley
s7anley / EvaluatorTest.php
Created August 17, 2016 11:18
withCallback
<?php
/**
* @dataProvider expressionsProvider
*/
public function testEvaluateReceiveCorrectExpression(Expression $expectedExpression)
{
$evaluator = $this->getMock(Evaluator::class);
$evaluator->expects($this->once())
->method('evaluate')
@s7anley
s7anley / array_maps.go
Last active February 19, 2016 15:00
Introduction to Go
package main
import (
"fmt"
)
func main() {
var array [5]float64
array[0] = 98
@s7anley
s7anley / Zend_Auth_Adapter_BcryptDbTable.php
Created November 17, 2015 22:35
Zend_Auth_Adapter_BcryptDbTable
<?php
class Base_Auth_Adapter_BcryptDbTable extends Zend_Auth_Adapter_DbTable
{
/**
* @inheritdoc
*/
protected function _authenticateCreateSelect()
{
$dbSelect = clone $this->getDbSelect();
@s7anley
s7anley / isUp.sh
Last active September 28, 2015 08:56
Is up?
#!/usr/bin/env bash
echo 'Enter host you want to ping:';
read PHOST;
if [[ "$PHOST" == "" ]]; then
exit;
fi
while true;
@s7anley
s7anley / Capfile
Created October 28, 2014 10:26
Easy local deployment of PHP applications with Capistrano 2
require 'railsless-deploy'
load 'path/to/script/deploy'
@s7anley
s7anley / pre-commit-php-cs-fixer.sh
Last active August 29, 2015 14:05
Pre commit php-cs-fixer
#!/bin/bash
PROJECTROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
FIXER=php-cs-fixer.phar
if [ ! -e ${PROJECTROOT}${FIXER} ]; then
echo "PHP-CS-Fixer not available, downloading to ${PROJECTROOT}${FIXER}..."
curl -s http://cs.sensiolabs.org/get/$FIXER > ${PROJECTROOT}${FIXER}
echo ""
fi
@s7anley
s7anley / analytics.js
Created April 23, 2014 11:32
Tracking GA events before redirect.
_gaq.push(
['_trackEvent', 'Category', 'Action', 'Label'],
function() {
window.location.href = '/';
}
);