Skip to content

Instantly share code, notes, and snippets.

View xboston's full-sized avatar

Nikolay Kirsh xboston

View GitHub Profile
@xboston
xboston / Timestampable.php
Created April 8, 2014 09:44
phalcon timestampable trait
<?php
namespace ShareModels\Traits {
use Phalcon\Mvc\Model\Behavior\Timestampable as TimestampableBehavior;
/**
* Class Timestampable
*
* @method addBehavior
>>> 0x7f6a92e01c20 1 zim_Phalcon_Mvc_View_Engine_Volt_Compiler_expression
>>> 0x7f6a92e01bd0 1 zim_Phalcon_Mvc_View_Engine_Volt_Compiler_expression
>>> 0x7f6a92e01b80 1 zim_Phalcon_Mvc_View_Engine_Volt_Compiler_expression
>>> 0x7f6a92e01b30 1 zim_Phalcon_Mvc_View_Engine_Volt_Compiler_expression
>>> 0x7f6a92e01ae0 1 zim_Phalcon_Mvc_View_Engine_Volt_Compiler_expression
>>> 0x7f6a92e01a90 1 zim_Phalcon_Mvc_View_Engine_Volt_Compiler_functionCall
>>> 0x7f6a92e01a40 1 zim_Phalcon_Mvc_View_Engine_Volt_Compiler_expression
>>> 0x7f6a92e019f0 1 zim_Phalcon_Mvc_View_Engine_Volt_Compiler_compileEcho
>>> 0x7f6a92e019a0 1 zim_Phalcon_Mvc_View_Engine_Volt_Compiler__statementList
>>> 0x7f6a92e01950 1 zim_Phalcon_Mvc_View_Engine_Volt_Compiler_compileForeach
@xboston
xboston / deploy.rb
Created January 25, 2014 08:16 — forked from jmather/deploy.rb
after "deploy", "deploy:cleanup"
after "deploy:update_code", "composer:install"
before "composer:install", "composer:copy_vendors"
after "composer:install", "phpunit:run_tests"
namespace :composer do
desc "Copy vendors from previous release"
task :copy_vendors, :except => { :no_release => true } do
run "if [ -d #{previous_release}/vendor ]; then cp -a #{previous_release}/vendor #{latest_release}/vendor; fi"
end
@xboston
xboston / trait-test.php
Created January 24, 2014 12:32
Trait test
<?php
/**
* Class fuck
*/
trait fuck
{
public function test()
{
@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(
@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 / 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-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(
<?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 / 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