Skip to content

Instantly share code, notes, and snippets.

View liuggio's full-sized avatar

Giulio De Donato liuggio

  • Radical Company
  • London
View GitHub Profile
@liuggio
liuggio / MyWarmer.php
Last active August 29, 2015 13:56
caches
<?php
namespace Acme\Foo;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
class FooCacheWarmer implements CacheWarmerInterface
{
public function isOptional()
{
liuggio = new Employee();
liuggio.createdAt = new Datetime("now")
liuggio.salaryPrice = 9999999.00
liuggio.salaryCurrency = "EUR"
liuggio.name = "liuggio"
if not externalValidator.validate(liuggio, context) {
return error
}
@liuggio
liuggio / factotum.feature
Last active August 29, 2015 14:02
draft of factotum
Feature: Build
In order to build classes
As a feature developer
I need to have an ability to use the factory traits.
Scenario: Build a Class using private methods
Given a file named "Customer.php" with:
"""
<?php
@liuggio
liuggio / initORM.php
Created September 24, 2014 11:05
initORM.php
#!/usr/bin/env php
<?php
function executing($cmd) {
echo $cmd.PHP_EOL;
system($cmd);
}
function runInit($env) {
executing('php app/console --env='. $env .' doctrine:database:drop --force');
@liuggio
liuggio / UseCaseInvoke.php
Last active August 29, 2015 14:07
Alternative approach using the invoke magic call.
<?php
/**
* We are used to create Commands/UseCases with a single method,
* is very common to create the name of the method with `execute`
* `$doSomething->execute($thisDay)`
* or to create the method name repeating the expressive class name:
* `$doSomething->doSomething($thisDay)`.
*
* This gist uses the magic call invoke
@liuggio
liuggio / PartnerManager.php
Created February 10, 2012 14:26
phpunit-closure best practice
/**
* insert a new row into the Entity trackVisit
*
* @param int $affiliateCampainId
* @param string $ipAddress
*/
public function trackVisit($affiliateCampainId, $ipAddress)
{
$visit = new trackVisit();
$visit->setIdentifier($affiliateCampainId);
@liuggio
liuggio / Yahoo Search Marketing.js
Created March 2, 2012 15:18
Yahoo! Search Marketing
<SCRIPT language="JavaScript" type="text/javascript">
<!-- Yahoo! Search Marketing
window.ysm_customData = new Object();
window.ysm_customData.conversion = "transId=1,currency=2,amount
=3";
var ysm_accountid = "1TGFOC61CVR7IG61MK9SVDEMIDG";
document.write("<SCR" + "IPT language='JavaScript' type='text/
javascript' "
+ "SRC=//" + "qasrv1.wa.marketingsolutions.yahoo.com" +
"/script/ScriptServlet" + "?aid=" + ysm_accountid
@liuggio
liuggio / app-config-config.yml
Created April 19, 2012 12:53
Symfony2 assets on RackSpace Cloud files [config.yml, parameter.ini]
framework:
# ...
templating:
# ...
packages:
## if you want to redirect just some asset remember to add also into twig file the package='rscf'
rscf:
base_urls: [%rackspace_container_url%]
## or use the generic:
# assets_base_urls:
@liuggio
liuggio / UsingGitHubAsAssetsCloudFiles-.git-hooks-post-commit
Created April 20, 2012 08:11
symfony2 store your assets into the github
#!/bin/sh
# in you /UsingGitHubAsAssetsCloudFiles/.git/hooks/post-commit
git push origin master
@liuggio
liuggio / bulkRename.sh
Created May 24, 2012 14:57
Bulk recursive rename dirs and files
#!/bin/bash
# $1 is the var
# $2 is replace from
# $3 is replace to
EXPECTED_ARGS=3
E_BADARGS=65
HELP=$(cat <<EOF
Usage with three arguments:
`basename $0` /var/www/path/ typo type