Skip to content

Instantly share code, notes, and snippets.

@freema
freema / imagecreatefrombmp.php
Last active September 2, 2015 07:21
Php imagecreatefrombmp
<?php
/**
* @param string $fileName
* @return resource
*/
function imagecreatefrombmp($fileName) {
$file = fopen($fileName, "rb");
$read = fread($file, 10);
while (!feof($file) && ($read <> ""))
@freema
freema / TreeModel.php
Last active August 29, 2015 14:02
PHP array TreeModel
namespace Utils;
/**
* Description of TreeModel
* @author Tomaš Grasl <grasl.t@centrum.cz>
* @category utils
* Slouží pro vytvoření stromové struktury
* <code>
* $createTree = new Utils/TreeModel();
* $createTree->setKey('id_modul');
* $createTree->setParentKey('group');
@freema
freema / NeonBulder.php
Last active August 29, 2015 14:02
NeonBulder
<?php
namespace Model;
use Exception;
use Nette\DI\Config\Adapters\NeonAdapter;
use Nette\IOException;
use Nette\Utils\Neon;
/**
* Description of NeonBuilder
@freema
freema / @layout.latte
Created January 30, 2015 10:07
Nette separate rendering of js and html content
{control test:HTML}
{control test:JS}
@freema
freema / gist:edb7849805e99e0b9cbf
Last active September 1, 2016 07:36
Nette twitter boostrap 3 submit to button
<?php
$form = new Form();
$form->addSubmit('submit', NULL)
->setAttribute("title", "vložení do košíku")
->setAttribute("alt", "vložení do košíku");
$vybratBtn = $form['submit']->getControlPrototype();
$vybratBtn->setName("button");
$vybratBtn->type = 'submit';
$vybratBtn->create('i class="fa fa-shopping-cart"');
@freema
freema / gist:3ed19d6160793d8cde5d
Last active August 29, 2015 14:14
Nette latte flashmessage by twitter boostrap 3
<div n:if="count($flashes) > 0" n:foreach="$flashes as $flash" role="alert" class="alert alert-{$flash->type}">
{$flash->message}
</div>
<div n:foreach="$flashes as $flash" class="alert alert-{$flash->type}">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
{$flash->message}
</div>
<?php
use Nette\Application\UI\InvalidLinkException;
use Nette\Application\UI\Presenter;
use Tracy\Debugger;
abstract class BasePresenter extends Presenter {
/**
* @param InvalidLinkException $e
@freema
freema / gwapiv2.txt
Last active November 29, 2016 14:53
Guild wars API v2 description
** Public API v2 **
Usage:
The API follows the general pattern of enumerating possible values of the
subsequent path segment, with the fully qualified path yielding a json object
of the type being enumerated.
For example, /v2/colors will yield:
[1, 2, 3, ... ]
@freema
freema / cursor.php
Created April 14, 2016 11:50
The array cursor same key restard
$array = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
$restart = TRUE;
while (list($key, $value) = each($array)) {
if($key === 5 && $restart) {
prev($array);
$restart = FALSE;
}
var_dump($key);
@freema
freema / config.neon
Created April 15, 2016 09:43
Nette presenter DI container params setter
services:
HomepagePresenter:
class: FrontModule\HomepagePresenter()
setup:
- $tempPath(%tempPath%)
#nebo
- FrontModule\HomepagePresenter()