Skip to content

Instantly share code, notes, and snippets.

View hhamon's full-sized avatar

Hugo Hamon hhamon

View GitHub Profile
class MoneyType extends AbstractType implements DataMapperInterface
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('amount', 'integer')
->add('currency', 'string')
->setDataMapper($this)
;
}
@frastel
frastel / build-lock.xml
Created February 20, 2013 09:42
Ant target for executing composer.lock vulnerability check provided by SensioLabs https://security.sensiolabs.org without using the CLI command. The command "ant lock_check" will do everything you need for this check. The definition assumes existing folder structure from http://jenkins-php.org/, you may want to modify those paths.
<?xml version="1.0" encoding="UTF-8"?>
<project name="Project-name-here" default="build" basedir=".">
<target name="lock_check" description="Checks for vulnerabilities through a SensioLabs web service"
depends="lock_reset,lock_get,lock_show">
<local name="vulnerabilities.clean"/>
<loadfile property="vulnerabilities.clean"
srcfile="${basedir}/build/logs/check_lock.log">
<filterchain>
@andreiz
andreiz / classifier.php
Last active July 12, 2022 12:50
A simple example of logistic regression via gradient descent in PHP.
<?php
error_reporting(E_ALL);
define('NUM_FEATURES', 3);
// My dataset describes cities around the world where I might consider living.
// Each sample (city) consists of 3 features:
// * Feature 1: average low winter temperature in the city
// * Feature 2: city population, in millions
@nikic
nikic / accessors.markdown
Created October 13, 2012 11:22
Analysis of getter/setter usage in Symfony and Zend Framework

In order to get a bit of "hard data" on what accessors will actually be used for once they are introduced I wrote a small script that scans through a codebase, finds all getter and setter methods and checks them for various characteristics. (The analyze.php file in this Gist.)

Here are the results of running it on a Symfony (Standard) skeleton.

absoluteTotal        => 18516 (486.6%)
total                =>  3805 (100.0%)
skipped              =>   124 (  3.3%)
@beberlei
beberlei / DoctrineTestCase.php
Created September 14, 2012 21:14
Doctrine Test Setup
<?php
// tests/MyProject/Tests/DoctrineTestCase.php
namespace MyProject\Tests;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\ORM\EntityManager;
class DoctrineTestCase extends \PHPUnit_Framework_TestCase
{
protected $em;
@weaverryan
weaverryan / forms.html.twig
Created April 13, 2012 11:26
Some basic Twitter Bootstrap Symfony2 form customizations
{# for twitter bootstrap specifically #}
{% block field_row %}
{% spaceless %}
<div class="control-group {% if errors|length > 0 %}error{% endif %}">
{{ form_label(form, label|default(null)) }}
<div class="controls">
{{ form_widget(form) }}
{{ form_errors(form)}}
</div>
</div>
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#