Skip to content

Instantly share code, notes, and snippets.

View aurimasniekis's full-sized avatar

Aurimas Niekis aurimasniekis

View GitHub Profile
<?php
$server = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($server, '127.0.0.1', '9090');
socket_set_nonblock($server);
socket_listen($server);
$selectSockets = [$server];
$null = null;
<?php
$input = [10,20,40,60,100];
$result = [];
$first = false;
foreach ($input as $item) {
if (false === $first) {
$first = $item;
continue;
<?php
// A Action
$em = $this->getDoctrine()->getMamanger();
$em->persist($objectA);
$em->flush()
// B Action
$em = $this->getDoctrine()->getMamanger();
$em->persist($objectB);
<?php
new SomeKindAction(new SomeKindAction(new SomeKindAction(..new SomeKindActionWhich gives array())));
<?php
// Before
$em = $this->getDoctrine()->getManager();
$em->persist($input);
$em->flush();
$data = $this->getDataMapper()->map($input);
$client = $this->getElasticSearch()->index('index', 'type', $data);
<?php
function actions($input)
{
return new PipelineAction(
$input,
new SomeAction(),
new OtherAction()
);
}
<?php
function actions($input)
{
return new SequalAction(
new DoctrinePersitAction($input),
new ElasticSearchIndexAction('index', 'type', new DataMapAction('mapper', $input)),
new RedisCacheAction('some:data:' . $input->getId(), $input)
)
}
@aurimasniekis
aurimasniekis / merger.php
Last active December 3, 2015 03:51
Funct multi file function merger to single file
<?php
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
require_once __DIR__ . '/vendor/autoload.php';
$groups = ['Collection', 'String', 'Objects'];
foreach ($groups as $groupName) {
╰─➤ php /tmp/a.php
PHP TypeError: Argument 1 passed to a() must be callable, string given, called in /private/tmp/a.php on line 8 in /private/tmp/a.php on line 3
PHP Stack trace:
PHP 1. {main}() /private/tmp/a.php:0
PHP 2. a() /private/tmp/a.php:8
TypeError: Argument 1 passed to a() must be callable, string given, called in /private/tmp/a.php on line 8 in /private/tmp/a.php on line 3
Call Stack:
require "logger"
module Apple
class Logger < ::Logger
attr_accessor :program_name, :debug
def initialize program_name, save_logs, log_file, log_level
if save_logs
super(log_file)
else
super(STDOUT)