Skip to content

Instantly share code, notes, and snippets.

@stefanotorresi
stefanotorresi / wordpress-custom-login.php
Last active June 4, 2018 22:09
add these hooks to your theme's 'functions.php' to customize Wordpress login page
function myLoginLogo() {
?>
<style type="text/css">
.login h1 a {
height: 82px;
background-size: auto;
background-image: url('<?=get_template_directory_uri();?>/img/logo-login.png');
}
</style>
<?php
@stefanotorresi
stefanotorresi / facebook-invite.js
Created April 7, 2013 09:29
facebook invite to event
checkboxes = document.getElementsByName("checkableitems[]");
for (i=0;i<checkboxes.length;i++) {
var checkbox = checkboxes[i];
if (checkbox.type == "checkbox" && !checkbox.checked ) {
checkbox.click();
}
};
@stefanotorresi
stefanotorresi / git-branches-info.sh
Last active December 16, 2015 05:49 — forked from jasonrudolph/git-branches-by-commit-date.sh
show a list with info about the last commit of each branch.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ct %cr | %h %s" $branch | head -n 1` \| $branch; done | sort -r
<?php
return array(
'router' => array(
'routes' => array(
'contact' => array(
'type' => 'Literal',
'options' => array(
'route' => '/contacts',
'defaults' => array(
@stefanotorresi
stefanotorresi / SlideEntity.php
Last active December 19, 2015 12:49
data aware widget with zf2 and doctrine
<?php
/**
* @author Stefano Torresi (http://stefanotorresi.it)
* @license See the file LICENSE.txt for copying permission.
* ************************************************
*/
namespace MySlideshow;
use MyBase\Entity\Entity;
@stefanotorresi
stefanotorresi / FormFactory.php
Created July 9, 2013 15:29
custom input filter services
<?php
use Zend\Filter\FilterChain;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class FormFactory implements FactoryInterface
{
public function createService(ServiceLocatorInterface $serviceLocator)
{
$form = new Form();
@stefanotorresi
stefanotorresi / form-collection-example.php
Created October 25, 2013 14:48
Using a Zend\Form\Collection of hydrated fieldsets.
<?php
use Zend\Form\Fieldset;
use Zend\Form\Form;
use Zend\Form\View\Helper\Form as FormHelper;
use Zend\Form\View\HelperConfig;
use Zend\Stdlib\ArrayUtils;
use Zend\Stdlib\Hydrator\ObjectProperty;
use Zend\View\Renderer\PhpRenderer;
@stefanotorresi
stefanotorresi / bench.php
Last active December 26, 2015 19:59
Zend\Stdlib\ArrayUtils::merge() benchmark
<?php
include '../zf2/vendor/autoload.php';
$array = include 'config.php'; // ZendSkeletonApp merged configuration
$array2 = include 'config2.php'; // zf-apigility-skeleton merged configuration
$array3 = include 'config3.php'; // zf-apigility-skeleton merged configuration with a traversable
$cycle = isset($argv[1]) ? $argv[1] : 1000;
echo 'cycling '.$cycle.' times' . PHP_EOL;
@stefanotorresi
stefanotorresi / sm.config.php
Created January 13, 2014 12:01
ZF2 ServiceManager config example
<?php
return [
'factories' => [
'Db' => function ($sm) {
$dbConfig = $sm->get('db_config');
$db = new PDO(
$dbConfig['dsn'],
$dbConfig['user'],
@stefanotorresi
stefanotorresi / zf2-service-factory.php
Last active August 29, 2015 13:56
make service factories scope-independent.
<?php
$serviceManager = $serviceLocator instanceof AbstractPluginManager ?
$serviceLocator->getServiceLocator() : $serviceLocator;