Skip to content

Instantly share code, notes, and snippets.

@s7anley
s7anley / delete_local_branches
Last active December 20, 2015 02:59
Delete local already merged branches and update the local database of remote branches.
# Delete all branches already merged to current branch
git checkout master; git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
# Sync local database of remote branchces
git fetch -p
@s7anley
s7anley / update
Last active August 29, 2015 13:56
Update Enum Type Item (Label) in PostgreSQL
-- Update one label in custom enum type
UPDATE pg_enum SET enumlabel = 'new_value'
WHERE enumlabel = 'old_value' AND enumtypid = (
SELECT oid FROM pg_type WHERE typname = 'enum_type'
);
-- Add new label in custom type avaliable since PostgreSQL 9.1
ALTER TYPE enum_type ADD VALUE 'new_value' BEFORE 'old_value';
ALTER TYPE enum_type ADD VALUE 'new_value' AFTER 'old_value';
@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 = '/';
}
);
@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 / 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 / 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 / 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 / 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 / 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')

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: