Skip to content

Instantly share code, notes, and snippets.

@raulfraile
raulfraile / desymfony2017.md
Last active October 17, 2019 18:45
Slides de deSymfony 2017
@raulfraile
raulfraile / yamllint.php
Created June 2, 2015 09:13
YAML linter
<?php
<<<CONFIG
packages:
- "symfony/yaml: ~2.3"
CONFIG;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Parser;
$content = file_get_contents($argv[1]);
@raulfraile
raulfraile / jsonlint.php
Created June 2, 2015 08:42
JSON linter
<?php
<<<CONFIG
packages:
- "seld/jsonlint: 1.3.1"
CONFIG;
use Seld\JsonLint\JsonParser;
$parser = new JsonParser();
@raulfraile
raulfraile / servergrove.com.har
Created April 30, 2015 11:11
servergrove.com HAR file
This file has been truncated, but you can view the full file.
{
"log": {
"version": "1.2",
"creator": {
"name": "WebInspector",
"version": "537.36"
},
"pages": [
{
@raulfraile
raulfraile / servergrove_mail_checker.php
Created April 15, 2015 12:32
ServerGrove mail checker
<?php
<<<CONFIG
packages:
- "swiftmailer/swiftmailer: ~5.0"
CONFIG;
$from = $argv[1];
$to = $argv[2];
$transport = \Swift_SmtpTransport::newInstance('mail.servergrove.com', 25)
@raulfraile
raulfraile / study_group.md
Last active August 29, 2015 14:07
Study group

Study group

The goal of the study group is to learn together cool/advanced/edge stuff that we are not used to see in the PHP world, such as:

  • Turing machines
  • Data mining
  • Esoteric languages
  • Database internals
  • Data structures
  • Algorithms
<?php
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
class ContainsJavaValidator extends ConstraintValidator
{
public function validate($value, Constraint $constraint)
{
if (stripos($value, 'java') !== false) {
<?php
// validate input (don't allow jokes about java)
$content = $request->request->get('content');
if (stripos($content, 'java') !== false) {
throw new BadRequestHttpException('Java jokes are not allowed');
}
<?php
public function load(ObjectManager $manager)
{
$jokes = array(
'There’s no place like 127.0.0.1',
'If at first you don’t succeed; call it version 1.0',
'You know it’s love when you memorize her IP number to skip DNS overhead',
'Beware of programmers that carry screwdrivers',
'What color do you want that database?'