Skip to content

Instantly share code, notes, and snippets.

View wodCZ's full-sized avatar

Martin Janeček wodCZ

View GitHub Profile
@wodCZ
wodCZ / BooleanOrNullControl.php
Created December 17, 2015 09:58
BooleanOrNullControl for Nette framework
<?php
namespace Forms\Controls;
use Nette\Forms\Controls\RadioList;
class BooleanOrNullControl extends RadioList
{
<?php
use Kdyby;
use Kdyby\RabbitMq\Connection;
use Kdyby\RabbitMq\DI\RabbitMqExtension;
use Nette;
use Nette\Reflection\ClassType;
use PhpAmqpLib\Message\AMQPMessage;
use Tester;
[global]
error_log = /usr/local/etc/php/5.6/logs/php-fpm.log
daemonize = no
[www]
user = wod
group = staff
listen = 127.0.0.1:9000
@wodCZ
wodCZ / 01-server-config-in-git.md
Created February 11, 2016 14:47 — forked from juzna/01-server-config-in-git.md
Server Configuration in git

Server Configuration in git

With git you can have anything versioned. You're used to version your code, which is a bunch of files. Your server configuration (on Linux) is also just a bunch of files, so it can be versioned as well.

The idea is simple: create a git repository in /etc/ and commit everytime you change any configuration of your server. Written in code:

cd /etc
git init
git add .
<?php
namespace Libs\Utils;
use Kdyby\Doctrine\Entities\BaseEntity;
use Nette\ComponentModel\IContainer;
use Nette\Forms\Controls\BaseControl;
use Nette\Utils\ArrayHash;
@wodCZ
wodCZ / CartPreviewComponent.php
Created July 25, 2016 20:26
Component example
<?php
class CartPreviewComponent {
public function __construct(CartModel $cartModel, $userId){
$this->cartModel = $cartModel;
$this->userId = $userId;
}
public function render(){
@wodCZ
wodCZ / example.php
Last active August 31, 2016 13:30
example article component and usage
<?php
// presenter
class ArticlePresenter extends Presenter {
/** @var \App\Components\IArticleControl @inject */
public $articleControlFactory;
/** @var \App\Model\Articles @inject */
@wodCZ
wodCZ / getChange.php
Last active September 17, 2016 18:42 — forked from algb12/getChange.php
<?php
// This function takes an array of denominators for a currency and a sum, and returns an array describing the most efficient way to express the sum in terms of denominations.
// E.g. A sum, such as 200 EUR can be expressed in terms of 100x2, which is inefficient, as there is the denomination 200 for this job.
// The function will return the most efficient way to express the sum, not 100x2, but 200x1.
// Recommended to round both, the expected and actual value to 2 decimal places.
// FUNCTION
// getChange function
function getChange($sum, $denominations) {
<?php
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
class RoboFile extends \Robo\Tasks
{
const CONFIG_PATH = __DIR__ . '/app/config/config.local.neon';
@wodCZ
wodCZ / Dockerfile
Created August 15, 2017 14:16
cron container
FROM openjdk:alpine
WORKDIR /usr/src/app
COPY build /usr/src/app
CMD ["/usr/src/app/job.sh"]