Skip to content

Instantly share code, notes, and snippets.

<?php
function sortString($a, $b) {
return strcmp($a, $b);
}
function sortNumber($a, $b) {
return r_num_get(NULL, $a) - r_num_get(NULL, $b);
}
class RTableColumnType {
@novia713
novia713 / CA2M_behat.yml
Created December 16, 2019 13:44
Activity feature for CA2M behat
default:
formatters:
pretty:
verbose: true
paths: false
snippets: true
suites:
default:
contexts:
- FeatureContext
@novia713
novia713 / one_2_many.php
Created November 22, 2019 08:28
λx.z + λy.z = λxy.z
<?php
$to_one = function($name){
echo "Hola $name \n\r";
};
$to_many = function($arr) use ($to_one) {
return array_map($to_one, $arr);
};
@novia713
novia713 / my_array_column.php
Created September 6, 2019 11:36
my_array_column()
<?php
$obj_1 = new StdClass;
$obj_1->name = "Toby";
$obj_2 = new StdClass;
$obj_2->name ="Martha";
$obj_3 = new StdClass;
$obj_3->n = 5;
$ar1 = ['name'=> 'Paul'];
$ar2 = ['name'=> 'Jess'];
$ar3 = ['age'=> '19'];
@novia713
novia713 / Saludo.php
Created July 2, 2019 11:30
Loading a Functor class via Composer
<?php
namespace Acme\Leandro;
class Saludo {
public function __invoke($name){
echo "Hola $name !!";
}
}
@novia713
novia713 / function_builder.php
Created July 1, 2019 14:02
[PHP FUNCTIONAL PROGRAMMING PATTERNS] Function builder
<?php
$discount = function($percent){
return function($price) use ($percent){
return ($price - ($price * $percent * 0.01));
};
};
$half_off = $discount(50);
echo $half_off(500);
<?php
// © [email protected] 20190504
//
$battle_url = "https://www.mythereum.io/api/games/";
$player_url = "https://mythereum.io/api/players/";
$my_print= function($txt){
echo "$txt\n";
};
#!/bin/bash
cd /Users/leandro/docker/madriddigital-hospitales/
docker-compose stop
git pull --ff-only
docker-compose up -d --build
docker-compose exec php composer install -o
docker-compose exec php vendor/bin/drush cim
docker-compose exec php vendor/bin/drush entup
docker-compose exec php vendor/bin/drush updb
<?php
$head = function($a) {
return array_shift($a);
};
$tail = function($a) {
$first = array_shift($a);
return $a;
};
<?php
$file = "/Users/leandro/.console/version";
$saved_version = "0";
$saved_date = "";
if (file_exists($file)){
$fp = fopen($file, 'r');
list($saved_date, $saved_version) = explode("|", @fread($fp, filesize($file)));
}