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 / main.go
Last active December 30, 2022 07:17
Golang api code
package main
import (
"database/sql"
"fmt"
"log"
"net/http"
"time"
"os"
"strings"
@liuggio
liuggio / namespace_isolation.go
Last active November 9, 2016 02:24
// go build . // sudo ./c /bin/sh -c "hostname bo;hostname"
package main
import (
"fmt"
"os"
"os/exec"
// "syscall"
)
func main() {

Creare macchina virtuale

$ docker-machine create one -d virtualbox

docker-machine ssh one

edit /var/lib/boot2docker/profile (sotto debian /etc/default/docker)

EXTRA_ARGS='
@liuggio
liuggio / BindResult.php
Last active September 27, 2017 10:40
The DTO has its validation, the controller uses the negotiation lib to get the proper formatter (twig or json_encode), the binder validate and fill the dto and create a BindResult
class BindResult {
private $data;
private $errors;
function __construct($data, $errors)
{
$this->data = $data;
$this->errors = $errors;
@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 / 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 / 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 = 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 / 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
liuggio / largestfiles.sh
Created November 26, 2013 13:59
largest files and directories
FS='/';NUMRESULTS=20;resize;clear;date;df -h $FS; echo "Largest Directories:"; du -x $FS 2>/dev/null| sort -rnk1| head -n $NUMRESULTS| awk '{printf "%d MB %s\n", $1/1024,$2}';echo "Largest Files:"; nice -n 19 find $FS -mount -type f -ls 2>/dev/null| sort -rnk7| head -n $NUMRESULTS|awk '{printf "%d MB\t%s\n",($7/1024)/1024,$NF}'