Skip to content

Instantly share code, notes, and snippets.

@stephpy
stephpy / create-user.sh
Created January 14, 2020 23:14
Create config.yaml kubernetes
#!/bin/bash
# Create environment variables
USER=$1
USER_DIR=./$1
ENV={EDIT_ENV}
SERVER_API_URI=https://{EDIT_SERVER_API}:6443/
# create the user environment directory
mkdir -p $USER_DIR
@stephpy
stephpy / gist:8555330
Created January 22, 2014 08:30
Hard mode vim
map <Left> <Nop>
map <Right> <Nop>
map <Up> <Nop>
map <Down> <Nop>
class Container
{
public function getA()
{
$object = new A();
$object->addModule($this->getB()); // a la fin de addModule, il injecte le logger dans B
}
public function getB()
{
@stephpy
stephpy / gist:6339377
Created August 26, 2013 08:51
hoa\math
<?php
$operation = '1 + 1'; // ...
$visitor = new \Hoa\Math\Visitor\Arithmetic();
$compiler = \Hoa\Compiler\Llk::load(
new \Hoa\File\Read('hoa://Library/Math/Arithmetic.pp')
);
$visitor->visit(
<?php
$rule = "foo(foo,'bar') = in_array(1, ('1', '2'))";
$ruler = new Hoa\Ruler\Ruler();
$ruler->addFunction('foo', function(array $args) {
return $args[0] == $args[1];
});
$ruler->addFunction('in_array', function(array $args) {
return 1;
$rb = new \Hoa\Ruler\RuleBuilder();
$rb->or(
$rb->and(
$rb->equals($rb->context('foo'), 100),
$rb->notEquals($rb->context('baz'), 150),
$rb->not($rb->context('bar'))
),
$rb->in($rb->scalar('toto'), $rb->context('users'))
);
%skip space \s
// Scalars.
%token true true|TRUE
%token false false|FALSE
%token null null|NULL
// Comparator
%token isNot (is not|IS NOT)
%token is (is|IS)
// Logical operators
%token not NOT
@stephpy
stephpy / composer.json
Last active December 16, 2015 19:29
rule
{
"require": {
"php": ">=5.3.2",
"hoa/compiler": "master"
},
"autoload": {
"psr-0": {
"Rulez": "src/"
}
},
@stephpy
stephpy / .vimrc
Last active December 16, 2015 03:08
Vim tips
" Move to left/right on buffer
map <S-Left> :bN<cr>
map <S-Right> :bn<cr>
<?php
use \mageekguy\atoum;
$script->addTestAllDirectory(__DIR__.'/src/Acme/MyBundleBundle/Tests/Units');
$cliReport = $script->addDefaultReport();
$cliReport->addField(new atoum\report\fields\runner\result\logo());
$runner->addReport($cliReport);