Skip to content

Instantly share code, notes, and snippets.

Memcache serialization test (ext/memcache v2.2.7)
*** unsetKey ***
bool(false)
*** emptyKey ***
string(0) ""
*** falseKey ***
string(0) ""
@cgmartin
cgmartin / gist:10328349
Last active August 29, 2015 13:58
grunt-newer: Check for newer @import .less files
//
// grunt-newer:
// Check for newer @import .less files example
// See: https://github.com/tschaub/grunt-newer/issues/29
//
grunt.initConfig({
// ...
newer: {
options: {
override: function(taskName, targetName, filePath, time, include) {
@cgmartin
cgmartin / all-in-one.js
Created March 12, 2015 18:43
Node Proxy Example
'use strict';
var port = parseInt(process.env.PROXY_PORT || process.env.PORT || 8000);
process.env.PROXY_PORT = port;
process.env.STATIC_PORT = port + 1;
process.env.API_PORT = port + 2;
process.env.CHAT_PORT = port + 3;
require('./proxy-server');
require('./static-server');
@cgmartin
cgmartin / README.md
Last active August 29, 2015 14:22 — forked from domenic/README.md
Node git pre-commit hook

Here's how this works:

  • Include a git-hooks/ directory in your project, with these two files (plus other hooks if you want, written in a similar style).
  • Ensure the files under the git-hooks/ directory are executable: chmod 755 git-hooks/*
  • Add test script to your package.json, e.g.
    "scripts": {
        "test": "mocha"
 }
<?php
// Inside ZendTest\Form\View\Helper\FormSelectTest
public function getScalarOptionsDataProvider()
{
return array(
array(array('string' => 'value')),
array(array('int' => 1)),
array(array('int-neg' => -1)),
array(array('hex' => 0x1A)),
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
------------------------------------------------------------------------------
@cgmartin
cgmartin / gist:3004926
Created June 27, 2012 15:42
Float and NumberFormatter oddity
Old validators with Zend\Locale\Format, passing:
public function deLocaleStringsProvider()
{
return array(
array('1,3', true),
array('1000,3', true),
array('1.000,3', true),
array('1.3', false),
array('1000.3', false),
@cgmartin
cgmartin / pre-commit
Last active October 9, 2015 06:17
ZF2 Git pre-commit hook
#!/usr/bin/env php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP errors (lint), and make sure the
* code is PSR-2 compliant.
*
* Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
*/
@cgmartin
cgmartin / gist:3687761
Created September 9, 2012 22:43
MultiCheckbox example
$multicbElement
->setAttributes(array(
'id' => 'my-multicb',
'options' => array(
'Option 1' => 'option1',
'Option 2' => array(
'value' => 'option2',
'labelAttributes' => array(
'class' => 'checkbox inline zf-green'
),
@cgmartin
cgmartin / gist:4156849
Created November 27, 2012 20:37
Create common factories with closures
protected function createTableFactory($tableName) {
return function($sm) use ($tableName) {
$tableGateway = $sm->get(ucfirst($tableName) . 'TableGateway');
$tableClass = ucfirst($tableName) . 'Table';
$table = new $tableClass($tableGateway);
};
}
protected function createTableGatewayFactory($tableName) {
return function($sm) use ($tableName) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');