Skip to content

Instantly share code, notes, and snippets.

« Les fous, les marginaux, les rebelles, les anticonformistes, les dissidents, tous ceux qui voient les choses différemment, qui ne respectent pas les règles, vous pouvez les admirer ou les désapprouver, les glorifier ou les dénigrer, mais vous ne pouvez pas les ignorer. Car ils changent les choses, ils inventent, ils imaginent, ils explorent, ils créent, ils inspirent, ils font avancer l'humanité. Là où certains ne voient que folie, nous voyons du génie. Car seuls ceux qui sont assez fous pour penser qu'ils peuvent changer le monde, y parviennent » Think Different, Apple Computer

<?php
namespace tests\units;
require __DIR__ . '/../../order.php';
require __DIR__ . '/mageekguy.atoum.phar';
use
mageekguy\atoum
;
@mageekguy
mageekguy / gist:4233871
Created December 7, 2012 15:16
My atoum's vim commands
// First install the atoum plugin (https://github.com/atoum/atoum/wiki/atoum-et-VIM)
// Second, add these lines to your .vimrc or (much better) to your php ftplugin :
nnoremap <buffer> <silent> <CR> :Atoum<CR> // Using <Enter> run atoum for all methods of the current file
nnoremap <buffer> <silent> <C-CR> :Atoum --debug<CR> Using <Ctrl-Enter> run atoum in debug mode for all methods of the current file (https://github.com/atoum/atoum/wiki/Le-mode-%22debug%22)
nnoremap <buffer> <silent> <S-CR> :execute ':Atoum -m *::' . substitute(getline(search('.*function\s\+test[^(]\+(', 'cnb')), '.*function\s\+\(test[^(]\+\)(.*$', '\1', '')<CR> // Using <Shift-Enter> run atoum only for the current method of the current file, ie the method which has the cursor in it
<?php
$remoteFile = file_get_contents('ssh2.sftp://user:pass@example.com:22/path/to/file');
// See http://php.net/manual/en/wrappers.ssh2.php for more informations.
@mageekguy
mageekguy / gist:4713903
Last active January 5, 2017 21:07
Add code below in your .vimrc to see the Git previous version of the current file with :GitPrevious.
function! s:GitPrevious()
let _ = './' . expand('%')
let filetype = &filetype
execute ':silent! vsp ' . tempname()
execute ':silent! 0r !git show HEAD~1:' . _
execute ':silent! $d'
execute ':silent! set nomodifiable'
execute ':silent! set readonly'
execute ':silent! set ft=' . filetype
static public function relativise($path, $workingpath = null) {
if(is_null($workingpath)) $workingpath = self::CorrectPathSlashes(getcwd());
$path = preg_replace('#([^/]+/\.\.)#', '', $path);
$path = preg_replace('#(\./|/\.$)#', '', $path);
$path = preg_replace('#/{2,}#', '/', $path);
$path = preg_replace('#/$#', '', $path);
$workingpath = preg_replace('#([^/]+/\.\.)#', '', $workingpath);
$workingpath = preg_replace('#(\./|/\.$)#', '', $workingpath);
$workingpath = preg_replace('#/{2,}#', '/', $workingpath);
public function getRelativePathFrom(self $reference)
{
$referencePath = static::cleanPath($reference);
switch (true)
{
case $this->path == $referencePath:
return '.';
case $referencePath == '':
<?php
namespace tests\units;
require __DIR__ . '/../runner.php';
use
atoum,
path as testedClass
;
protected function mockAllSubLogMethods(atoum\mock\aggregator $mock)
{
$controller = $mock->getMockController();
foreach ($controller->getMockedMethods() as $method)
{
if ($method !== 'log')
{
$controller->{$method} = function() {};
}
@mageekguy
mageekguy / gist:5142226
Created March 12, 2013 11:36
Test of proc_open() with php under windows…
<?php
$php = proc_open('php', array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w')), $pipes);
fwrite($pipes[0], '<?php ');
for ($i = 0; $i <= 9000; $i++)
{
fwrite($pipes[0], '/');
}