Skip to content

Instantly share code, notes, and snippets.

@jmoz
jmoz / cooler prompt
Created August 19, 2009 09:46
cooler prompt
# grab the part of the repo url we want to display
svn_info() {
svn info 2> /dev/null | sed -n 's/^URL: svn:\/\/subversion\/symfony\/\(.*\)$/\1/p'
}
# Only echo if in an svn repo.
in_svn_repo() {
if [[ -d "./.svn" ]]; then
echo -e "\e[37;1mon \e[34;1m$(svn_info)"
fi
@jmoz
jmoz / svn diff with colours
Created August 19, 2009 14:31
svn diff with colours
# For the colours in the sed replacement to work this is the only way I can get bash to interpret them correctly.
RED=`echo -e '\033[31m'`
GREEN=`echo -e '\033[32m'`
WHITE=`echo -e '\033[37m'`
# Nice simple coloured svn diff.
alias svndiff="svn diff | sed -e \"s/^\([+].*\)/$GREEN\1$WHITE/\" -e \"s/^\([-].*\)/$RED\1$WHITE/\"";
@jmoz
jmoz / ls_colors
Created January 18, 2010 13:18
ls_colors file to change colour of ls
# di=5;34;43 Setting the LS_COLORS di parameter to the above example will make directories appear in flashing blue text with an orange background
#0 = Default Colour
#1 = Bold
#4 = Underlined
#5 = Flashing Text
#7 = Reverse Field
#31 = Red
#32 = Green
#33 = Orange
#34 = Blue
<?php
$request = new HttpRequest('http://symfony/foo', HTTP_METH_PUT);
$request->setHeaders(array('Content-Type' => 'application/x-www-form-urlencoded'));
$request->setPutData('content=bar');
$response = $request->send();
# fuck nano
export EDITOR=vim
alias sst='svn st | grep -P --color=never "^(\W|\w)" | grep -vP "^(X|Perf)"'
alias sup="svn up"
alias sd="svn diff"
alias sci="svn ci"
alias sr="svn revert"
alias sa="svn add"
alias si="svn info"
@jmoz
jmoz / gist:974567
Created May 16, 2011 14:49
Action example
<?php
public function executeWebServiceCall() {
$client = new ServiceClient(new FooService(), new Http());
$this->renderText($client->call());
}
@jmoz
jmoz / gist:974596
Created May 16, 2011 15:00
Client example
<?php
class ServiceClient {
private $service;
private $http;
public function __construct(Service $service, Http $http) {
$this->service = $service;
$this->http = $http;
@jmoz
jmoz / gist:974602
Created May 16, 2011 15:04
Client refactored 1
<?php
class ServiceClient {
private $service;
private $http;
private $logger;
public function __construct(Service $service, Http $http, sfLogger $logger) {
$this->service = $service;
@jmoz
jmoz / gist:974611
Created May 16, 2011 15:08
Action refactored 1
<?php
public function executeWebServiceCall() {
$client = new ServiceClient(new FooService(), new Http(), $this->getLogger());
$this->renderText($client->call());
}
@jmoz
jmoz / gist:974654
Created May 16, 2011 15:31
Client observer
<?php
class ServiceClient implements SplSubject {
private $service;
private $http;
private $observers;
public function __construct(Service $service, Http $http) {
$this->service = $service;