Skip to content

Instantly share code, notes, and snippets.

View mhf-ir's full-sized avatar

Mohammad Hossein Fattahizadeh mhf-ir

View GitHub Profile
@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 / 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;
@esurdam
esurdam / nginx_njs.md
Last active August 19, 2018 18:38
njs for nginx configuration

NJS/nginScript

Configure nginx with HTTP JavaScript module using the --add-module option:

./configure --add-module=<path-to-njs>/nginx

Alternatively, you can build a dynamic version of the njs module

./configure --add-dynamic-module=<path-to-njs>/nginx
@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',
@jankeromnes
jankeromnes / devices.js
Last active December 3, 2021 09:40
List of common devices and their properties
// This list of common devices was put together from various online sources by me, Jan Keromnes.
//
// The device features are:
// - name: The device brand and model(s).
// - width: The viewport width.
// - height: The viewport height.
// - pixelRatio: The screen's pixel ratio (e.g. HiDPI > 1).
// - userAgent: The device's UserAgent string on the web.
// - touch: Whether the device's screen is touch-enabled.
//