Skip to content

Instantly share code, notes, and snippets.

View ZhukV's full-sized avatar
🏠
Working from home

Vitaliy Zhuk ZhukV

🏠
Working from home
View GitHub Profile
@ZhukV
ZhukV / AttachModel.php
Created April 26, 2013 19:41
Abstract attach model for upload files in Symfony 2
<?php
namespace Acme\DemoBundle\Model;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* Abstract class for control attachments model (Image, flash, other files)
*
* For upload files in your entity please usage ORM\HasLifecycleCallbacks (preUpdate, prePersist)
@ZhukV
ZhukV / Box.php
Created May 22, 2013 07:15
Scale & crop filter to AvalacheImagine
<?php
namespace Acme\DemoBundle\Imagine\Filter;
use Imagine\Image\BoxInterface;
use Imagine\Image\PointInterface;
use Imagine\Image\Point;
/**
* Common box container, for allowed set width or height is zero
;(function(){
/**
* Event dispatcher system
*/
function EventDispatcher()
{
var _listeners = {};
/**
* Add listener
;(function ($) {
/**
* Event for collection
*/
function CollectionEvent(element)
{
var status = true;
/**
* Get element
<?php
namespace Acme\DemoBundle\Util;
use Doctrine\ORM\QueryBuilder;
/**
* Pagination
*/
class Pagination implements \Countable, \Iterator
@ZhukV
ZhukV / ExcelFileResponse.php
Created July 26, 2013 08:46
Excel file response for download excel files usage PHPExcel library (Symfony HttpFoundation)
<?php
namespace Acme\DemoBundle\HttpFoundation;
use Symfony\Component\HttpFoundation\Response;
/**
* Response for download excel file
*/
class ExcelFileResponse extends Response
@ZhukV
ZhukV / app.php
Created August 14, 2013 06:34
Check multiple implementation
<?php
interface iA
{
public function someA();
public function thisIs();
}
interface iB
{
@ZhukV
ZhukV / StreamHandler.php
Created October 1, 2013 17:57
Override monolog stream handler for auto create directory
<?php
namespace Acme\Demo\Monolog\Handler;
use Monolog\Handler\StreamHandler as BaseStreamHandler;
use Symfony\Component\Filesystem\Filesystem;
/**
* Auto create log directory, if directory not found.
* The base stream handler in monolog package not auto created
@ZhukV
ZhukV / CountryContinent.php
Created January 9, 2014 06:59
Grouping countries by continent
<?php
namespace Acme\Demo;
/**
* Parsed from http://timezone.help.ch/
*
* @author Vitaliy Zhuk <zhuk2205@gmail.com>
*/
class CountryContinent
@ZhukV
ZhukV / ds18b20.c
Created January 29, 2014 19:22
Work with temperature sensor DS18B20
/**
ds18b20.c - work with temperature sensor DS18B20
Author: Vitaiy Zhuk
*/
#include <util/delay.h>
#include "ds18b20.h"
/**