Skip to content

Instantly share code, notes, and snippets.

View mhf-ir's full-sized avatar

Mohammad Hossein Fattahizadeh mhf-ir

View GitHub Profile
@donatj
donatj / ColorCLI.php
Created October 26, 2011 03:34
Simple CLI color class
<?php
class ColorCLI {
static $foreground_colors = array(
'bold' => '1', 'dim' => '2',
'black' => '0;30', 'dark_gray' => '1;30',
'blue' => '0;34', 'light_blue' => '1;34',
'green' => '0;32', 'light_green' => '1;32',
'cyan' => '0;36', 'light_cyan' => '1;36',
@weierophinney
weierophinney / application.config.php
Created March 29, 2012 21:10
Proposed bootstrap for ZF2
<?php
return array(
'modules' => array(
'Application',
/* ... */
),
'module_listeners' => array(
'use_defaults' => true, /* false to disable them */
/* list additional module listeners to use here */
@DASPRiD
DASPRiD / gist:2404837
Created April 17, 2012 09:22
Locale or language in URL
<?php
use Zend\EventManager\StaticEventManager;
use Zend\Mvc\MvcEvent;
use Locale;
$events = StaticEventManager::getInstance();
$events->attach('Zend\Mvc\Application', 'route', function(MvcEvent $event){
$request = $event->getRequest();
$uri = $request->uri();
$baseUrlLength = strlen($request->getBaseUrl() ?: '');
@Ocramius
Ocramius / dic-dump.php
Created April 26, 2012 14:38
Generated Service Locator from Zend\Di\Di
<?php
return array (
'Zend\\EventManager\\EventManager' =>
array (
'instantiator' =>
array (
'name' => NULL,
'parameters' =>
array (
0 =>
@Ocramius
Ocramius / Compiled.php
Created May 2, 2012 23:38
ZF2 - DIC Compiler quick performance check
<?php
namespace Application\Dic;
use Zend\Di\Di;
class Compiled extends Di
{
public function newInstance($name, array $params = array(), $isShared = true)
// zend framework è in /var/www/lib/Zend mentre il file che contiene l'autoloader è nella root
<?php
// Setting include_path to add library to included dirs
set_include_path(realpath(__DIR__ . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR .'Zend'.DIRECTORY_SEPARATOR. 'library') . PATH_SEPARATOR . get_include_path());
// Initializing autoloader
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
$dbh = new PDO('pgsql:user=garbezzano password=*a571992g* host=127.0.0.1 dbname=dbstrumenti');
?>
The following tasks need to be done to finish the i18n component:
------------------------------------------------------------------------------
To finish translator:
- Add Xliff translation loader with plural support if possible, see:
https://wiki.oasis-open.org/xliff/XLIFF2.0/Feature/Plural%20Entries
- Add Tmx translation loader (identify if plural support is available)
- Complete unit tests
------------------------------------------------------------------------------
@Ocramius
Ocramius / User.php
Last active February 16, 2024 14:57
Doctrine 2 ManyToMany - the correct way
<?php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity()
* @ORM\Table(name="user")
*/
class User
@Ocramius
Ocramius / LazyLoadableObject.php
Created November 8, 2012 10:30
DCOM-96 generated proxy example
<?php
/**
* @author Marco Pivetta <ocramius@gmail.com>
*/
class LazyLoadableObject
{
public $publicIdentifierField;
protected $protectedIdentifierField;
@blackfalcon
blackfalcon / git-feature-workflow.md
Last active April 13, 2024 07:33
Git basics - a general workflow

Git-workflow vs feature branching

When working with Git, there are two prevailing workflows are Git workflow and feature branches. IMHO, being more of a subscriber to continuous integration, I feel that the feature branch workflow is better suited, and the focus of this article.

If you are new to Git and Git-workflows, I suggest reading the atlassian.com Git Workflow article in addition to this as there is more detail there than presented here.

I admit, using Bash in the command line with the standard configuration leaves a bit to be desired when it comes to awareness of state. A tool that I suggest using follows these instructions on setting up GIT Bash autocompletion. This tool will assist you to better visualize the state of a branc