Skip to content

Instantly share code, notes, and snippets.

View xboston's full-sized avatar

Nikolay Kirsh xboston

View GitHub Profile
<?php
error_reporting( E_ALL | E_NOTICE | E_STRICT );
/**
* SQL for model:
CREATE TABLE `temp` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;
*/
<?php
// -- test1 ---------
// throw Phalcon\Tag\Exception: A dependency injector container is required to obtain the "escaper" service
Phalcon\Tag::setDefault("name", "test");
echo Phalcon\Tag::getValue("name");
<pre><?php
$di = new Phalcon\DI\FactoryDefault();
\Phalcon\Tag::getEscaperService();
$string = 'Русский';
Phalcon\Tag::setDefault("name", $string);
echo $string;
@xboston
xboston / gist:6130534
Created August 1, 2013 11:31
php torrent seed+leeches http udp
<?php
class Torrent
{
public function scrape(array $announce = [ ] , $hash_info = null)
{
$r = [
'seeders' => 0 ,
'leechers' => 0
@xboston
xboston / gist:6130535
Last active December 20, 2015 12:19
php torrent seed+leeches http udp
<?php
class Torrent
{
public function scrape(array $announce = [ ] , $hash_info = null)
{
$r = [
'seeders' => 0 ,
'leechers' => 0
<?php
$compiler = new \Phalcon\Mvc\View\Engine\Volt\Compiler();
$compiler->addFunction('not_empty', '!empty');
echo highlight_string($compiler->compileString('
{% if not_empty(userinfo.vk) %}
<a id="vk" href="{{ userinfo.vk }}">vk</a>
@xboston
xboston / phalcon-models.php
Created September 17, 2013 08:27
Phalcon model public/protected var's test
<?php
use Phalcon\DI , Phalcon\Db\Adapter\Pdo\Mysql as Connection , Phalcon\Mvc\Model\Manager as ModelsManager , Phalcon\Mvc\Model\Metadata\Memory as MetaData , Phalcon\Mvc\Model;
$di = new DI();
//Setup a connection
$di->set(
'db' ,
new Connection(array(
@xboston
xboston / phalcon volt addFilter addFunction.php
Created September 17, 2013 10:22
Phalcon volt - addFunction vs addFilter
<?php
$compiler = new \Phalcon\Mvc\View\Engine\Volt\Compiler();
$compiler->addFunction("test1", function($resolvedArgs, $exprArgs) {
$value = $exprArgs[0]['expr']['value'];
return str_replace('$', '&euro;', $value);
});
@xboston
xboston / phalcon-events.list
Created December 24, 2013 19:08
Phalcon events:list
dispatch:beforeDispatchLoop
dispatch:beforeDispatch
dispatch:beforeNotFoundAction
dispatch:beforeExecuteRoute
dispatch:afterInitialize
dispatch:afterExecuteRoute
dispatch:afterDispatch
dispatch:afterDispatchLoop
dispatch:beforeException
@xboston
xboston / gist:8334860
Created January 9, 2014 14:24
Phalcon notFound test
<?php
$router = new Phalcon\Mvc\Router(false);
$router->notFound(array(
'controller' => 'user',
'action' => 'show404'
));
$router->add('/login/', array(