Skip to content

Instantly share code, notes, and snippets.

@Herzult
Herzult / http.go
Created January 12, 2024 01:37
JSON Stream Golang
package jsonstream
import (
"encoding/json"
"fmt"
"io"
"net/http"
"sync"
)
@Herzult
Herzult / FormTextTreeRenderer.php
Last active August 29, 2015 14:00
Text tree renderer form Symfony forms
<?php
use Symfony\Component\Form\FormInterface;
class FormTextTreeRenderer
{
public function render(FormInterface $form)
{
$lines[] = '.';
$lines[] = $this->renderNode($form);
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.share_folder "v-root", "/vagrant", ".", :nfs => true
config.vm.network :hostonly, "192.168.50.4"
config.vm.forward_port 80, 8080
@Herzult
Herzult / book-links.js
Created November 29, 2012 12:41
JSON Schema link exemple
@Herzult
Herzult / ArrayWrapper.php
Created September 8, 2011 16:11
Small array wrapper
<?php
class ArrayWrapper
{
private $array;
/**
* Constructor
*
* @param array $array
@Herzult
Herzult / Benchmark.php
Created September 2, 2011 14:19
A practical benchmark class
<?php
class Benchmark
{
private $closure;
private $numTimes;
private $resultSet;
public function __construct(\Closure $closure, $numTimes = 1, $autorun = false)
{
@Herzult
Herzult / CustomizableFileLocator.php
Created May 23, 2011 12:38
POC of a customizable file locator (ease the share of a Symfony project)
<?php
/**
* File locator that first look for a "filename.local.ext" when the name of the
* file to locate matches the "filename.customizable.ext" pattern, then it look
* for a "filename.ext" file.
*/
class CustomizableFileLocator extends FileLocator
{
/**
@Herzult
Herzult / WhatTheFuck.php
Created February 22, 2011 12:37
No comment...
<?php
class Test
{
public function whatTheFuck()
{
${'thi' . 's'} = 'tata';
var_dump($this);
var_dump($this->getThis());
@Herzult
Herzult / Client.php
Created February 11, 2011 08:15
Quick fix to make session work for a single client in tests
<?php
namespace MyVendor\MyBundleBundle\Test;
use Symfony\Bundle\FrameworkBundle\Client as BaseClient;
use Symfony\Component\BrowserKit\Cookie;
class Client extends BaseClient
{
/**
@Herzult
Herzult / UserGroup.class.php
Created November 4, 2010 15:07
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
<?php
class UserGroup extends BaseUserGroup
{
/**
* Overwrites the parent getName to return a translated string
*
* @return translated name as string
*/
public function getName()