Skip to content

Instantly share code, notes, and snippets.

View vnagara's full-sized avatar

Vitalii Nagara vnagara

  • Internet Guru
  • Romania
View GitHub Profile
@vnagara
vnagara / history of commands.sh
Last active December 15, 2015 19:29
git gc don't work properly
duke@webmaker ~/tmp/c $ git --version
git version 1.8.2
duke@webmaker ~/tmp/c $ ll
total 80K
drwxr-xr-x 3 duke duke 4.0K Apr 4 17:13 .
drwxrwxrwt 23 root root 64K Apr 4 17:17 ..
-rw-r--r-- 1 duke duke 3 Apr 4 16:43 a
drwxr-xr-x 7 duke duke 4.0K Apr 4 17:20 .git
duke@webmaker ~/tmp/c $ rm -r .git/
rm: remove all arguments recursively? y
$ time composer require --no-update
Search for a package []: symfony/symfony
Found 44 packages matching symfony/symfony
[0] symfony/symfony 2.0.7
[1] symfony/symfony v2.0.10
[2] symfony/symfony v2.0.11
[3] symfony/symfony v2.0.12
[4] symfony/symfony v2.0.13
@vnagara
vnagara / container.php
Created April 11, 2013 17:16
Zf2 session container fall test
<?php
ini_set('display_errors', 1);
chdir(dirname(__DIR__));
require 'init_autoloader.php';
$container = new \Zend\Session\Container('name1');
var_dump($container->offsetGet('f'));
$container->offsetSet('f', 'val');
var_dump(session_id());
@vnagara
vnagara / log
Created April 26, 2013 12:36
zf2 unit tests log
Linux webmaker 3.2.0-32-generic #51-Ubuntu SMP Wed Sep 26 21:33:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
PHP 5.4.14-1~precise+1 (cli) (built: Apr 11 2013 17:09:50)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
git: 01527ba [Thu Apr 25 14:28:04 2013 -0500] (HEAD, origin/develop) Fix navigation menu helper tests <Matthew Weier O'Phinney>
@vnagara
vnagara / 3 entities.php
Last active December 19, 2015 16:19
doctrine problem
<?php
/**
* Class Site
* @ORM\Entity
* @ORM\Table(name="ad_posting_site",
* uniqueConstraints={@ORM\UniqueConstraint(name="display_name", columns={"display_name"})}
* )
*/
class Site extends AbstractEntityParams
@vnagara
vnagara / Module.php
Last active August 29, 2015 13:56
Adding new fields to Article Form
<?php
public function onBootstrap(MvcEvent $e)
{
$sharedManager = $e->getApplication()->getEventManager()->getSharedManager();
$sharedManager->attach('LibraArticle\Controller\ArticleController', 'dispatch', function($e) {
// Add current article to layout
$controller = $e->getTarget();
$controller->getEventManager()->attach('view', function($e) {
$article = $e->getParam('article');
$controller = $e->getTarget();
<?php
/**
* Example action
* This is an example action that tests binding of forms to entities.
* @return \Zend\View\Model\ViewModel
*/
public function exampleAction()
{
$node = new \ArrayObject(array(
return array(
'di' => array(
'instance' => array(
'Zend\View\Resolver\AggregateResolver' => array(
'injections' => array(
'Zend\View\Resolver\TemplateMapResolver',
'Zend\View\Resolver\TemplatePathStack',
'Zend\View\Resolver\RelativeFallbackResolver',
'Zend\View\Resolver\RelativeFallbackResolver2',
),
{"myAdEntries":[{"id":"1034716359","date":1416747378000,"url":"/v-view-details.html?adId=1034716359","active":true,"title":"POST RENOVATION, POST CONSTRUCTION CLEANING : 289-644-9139","price":"","locationName":"Toronto (GTA) > Oakville / Halton Region","expired":false,"promoting":false,"expirationDate":1421931378000,"pageNumber":"1","viewCounter":0,"delayed":false,"teaserUrl":"//secureimg.ebayimg.com/00/s/MTgzWDE0MA==/z/I28AAOSwd4tTuuut/$_2.JPG","canEditPrice":false,"showExpirationDate":false,"showViewCounter":true,"showPageNumber":true,"canConfirm":false,"canEdit":true,"canRepost":false,"canDelete":true,"expiring":false,"repostSurveyReasons":[{"messageKey":"my.ads.survey.notEnoughResponses","name":"NOT_ENOUGH_RESPONSES","other":false,"preferNotToSay":false},{"messageKey":"my.ads.survey.simlarActivityOrEventToPromote","name":"SIMLAR_ACTIVITY_OR_EVENT_TO_PROMOTE","other":false,"preferNotToSay":false},{"messageKey":"my.ads.survey.preferNotToSay","name":"PREFER_NOT_TO_SAY","other":false,"preferNotToSay":true}],"
<?php
/* Setup page vars for display. */
if ($page == 0) $page = 1; //if no page var is given, default to 1.
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
/*
Now we apply our rules and draw the pagination object.
We're actually saving the code to a variable in case we want to draw it more than once.