Skip to content

Instantly share code, notes, and snippets.

@shadowhand
shadowhand / git_extdeps.sh
Last active August 29, 2015 13:56
Search for external static deps using git grep
# Git grep for external static deps (ignores static:: and self:: calls)
alias staticdeps="git grep -Pi '^(?!\s+[*\/]).+\b[a-z][a-z0-9_]++(?<!static|self)::'"
# can also be assigned as a git alias
# add --global if you want it everywhere
git config alias.extdeps "grep -Pi '^(?"'!'"\s+[*\/]).+\\b[a-z][a-z0-9_]++(?<"'!'"static|self)::'"
# usage, global search
git extdeps
@shadowhand
shadowhand / git-switchbranch
Last active August 29, 2015 13:57
Fast git branch switching (git-switchbranch)
#!/bin/bash
######################################################################################
# THIS GIST IS NO LONGER MAINTAINED AND MAY BE DELETED IN THE FUTURE! #
# PLEASE GO TO https://github.com/shadowhand/git-switchbranch FOR A CURRENT VERSION! #
######################################################################################
# git-switchbranch
# @link https://gist.github.com/shadowhand/9813453
# @author shadowhand https://github.com/shadowhand
@shadowhand
shadowhand / geeksphone_android_downloads.md
Last active August 29, 2015 13:58
List of Geeksphone Android releases with download links
@shadowhand
shadowhand / RegisterSpec.php
Created May 1, 2014 20:01
phpspec test with errors.
<?php
namespace spec\Ushahidi\Usecase\User;
use Ushahidi\Entity\User;
use Ushahidi\Entity\UserRepository;
use Ushahidi\Tool\Validator;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
@shadowhand
shadowhand / Register.php
Last active August 29, 2015 14:00
a "user can register" use case
<?php
namespace Ushahidi\Usecase\User;
use Ushahidi\Entity\User;
use Ushahidi\Entity\UserRepository;
use Ushahidi\Tool\Validator;
class Register
{
@shadowhand
shadowhand / Register.php
Last active August 29, 2015 14:00
register controller using use case
<?php
/* snip */
$parser = $app->get('user.parse.register');
$usecase = $app->get('usecase.user.register');
$params = $this->request->post();
try
{
$user = $parser($params);
@shadowhand
shadowhand / RegisterSpec.php
Created May 1, 2014 23:49
spec for "user can register" use case
<?php
namespace spec\Ushahidi\Usecase\User;
use Ushahidi\Entity\User;
use Ushahidi\Entity\UserRepository;
use Ushahidi\Tool\Validator;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
@shadowhand
shadowhand / Login.php
Created May 4, 2014 01:06
user login use case
<?php
namespace Ushahidi\Usecase\User;
use Ushahidi\Entity\User;
use Ushahidi\Entity\UserRepository;
use Ushahidi\Tool\Validator;
use Ushahidi\Tool\PasswordAuthenticator;
use Ushahidi\Exception\Login as LoginException;
new DataProviderModel({
id: 'email',
name: 'Email Server',
type: 'email',
enabled: true,
config: {
'server': 'mail.example.com',
'port': 25,
'username': 'user@example.com',
'password': 'secret'