Skip to content

Instantly share code, notes, and snippets.

View Djuki's full-sized avatar

Ivan Đurđevac Djuki

  • Freelancer
  • Serbia
  • 15:32 (UTC -12:00)
  • X @Djuki
View GitHub Profile
@Djuki
Djuki / javascript_in_php
Created September 26, 2011 08:35
Mix javascript and php
$javascript = <<<JS
function javascriptFunction()
{
/* Some javascript code here */
}
JS;
@Djuki
Djuki / injection1.php
Last active December 9, 2015 23:39
Primer korišćenja IoC containera
<?php
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
// Create IoC container
$container = new ContainerBuilder();
// Register Engine object and parameter for constructor
$container->register('my.engine', '\\Model\\Engine')
@Djuki
Djuki / injection2.php
Last active December 9, 2015 23:39
Primer korišćenja IoC containera uz setter metode
<?php
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
class Tractor
{
/**
* Engine
*
@Djuki
Djuki / injection3.php
Last active December 9, 2015 23:48
Primer korišćenja IoC containera
<?php
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
class Engine
{
private $cubic;
/**
use DI\Annotations\Inject;
class Foo {
/**
* @Inject
* @var Bar
*/
private $bar;
public function __construct() {
@Djuki
Djuki / traktor2b.php
Created February 7, 2013 20:37
DI with setter method
class Tractor
{
protected $engine;
public function setEngine($engine)
{
$this->engine = $engine;
}
}
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
$container = new ContainerBuilder();
$loader = new XmlFileLoader($container, new FileLocator(__DIR__));
$loader->load('services.xml');
@Djuki
Djuki / menu_data_raw.php
Last active December 15, 2015 07:38
Proper way to print root menu items and child menu items in separated div's.
<?php
$menu = array(
0 => array('display' => 'Writers', 'url' => 'http://www.famousauthors.org/', 'sub' => array(
array('display' => ' Alan Moore', 'url' =>'http://www.famousauthors.org/alan-moore'),
array('display' => ' Dan Brown', 'url' =>'http://www.famousauthors.org/dan-brown'),
array('display' => ' Mario Puzo', 'url' =>'http://www.famousauthors.org/mario-puzo'),
)),
1 => array('display' => 'Musicians', 'url' => 'http://www.thefamouspeople.com/musicians.php', 'sub' => array(
array('display' => ' Composer', 'sub' => array(
@Djuki
Djuki / PingPong.java
Last active December 15, 2015 16:59
PingPong synchronization with main thread in several programming languages
class PingPongThread extends Thread {
/**
* Message for print
*/
private String message;
/**
* Main Application thread
*/
@Djuki
Djuki / VideoThumbnail.php
Last active December 18, 2015 15:28
Create youtube image with play button and scrubber
<?php
/**
* Get image for video preview
*
* @param $videoId
*
* @return string
*/
public function createVideoImage($videoId)