Skip to content

Instantly share code, notes, and snippets.

View immutef's full-sized avatar

immutef

  • SCAYLE GmbH
  • Hamburg, Germany
View GitHub Profile
@immutef
immutef / TestCommand.php
Created December 10, 2011 12:56
ZeroMQ Fan In/Out + Kill
<?php
/**
* I'd like to use IPC sockets (ipc://foo.ipc) but my virtual machine won't let me ... :)
* IPC sockets will be faster than TCP, so this script could run even faster than it does!
*/
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputOption;
@henrikbjorn
henrikbjorn / RelDate.php
Created December 5, 2011 08:01 — forked from arnaud-lb/RelDate.php
4 lines relative date formatter with DateInterval and Symfony2 Translator
<?php
use Symfony\Component\Translation\TranslatorInterface;
function format(\DateTime $date, TranslatorInterface $translator)
{
$diff = date_create()->diff($date);
$seconds = $diff->days * 86400 + $diff->h * 3600 + $diff->i * 60 + $diff->s;
$format = $translator->transChoice('reldate', $seconds);
@arnaud-lb
arnaud-lb / RelDate.php
Created December 4, 2011 14:12
4 lines relative date formatter with DateInterval and Symfony2 Translator
<?php
use Symfony\Component\Translation\TranslatorInterface;
function format(\DateTime $date, TranslatorInterface $translator)
{
$diff = date_create()->diff($date);
$seconds = $diff->days * 86400 + $diff->h * 3600 + $diff->i * 60 + $diff->s;
$format = $translator->transChoice('reldate', $seconds);
@monde
monde / README
Created November 8, 2011 22:08
how to build a vagrant box image
= Ubuntu Natty 64 Server Vagrant Base Box
== Description
This is a Vagrant Base Box based upon the Ubuntu Natty 64 Server. It was built
according to the Vagrant Base Box building guide:
http://vagrantup.com/docs/base_boxes.html
This box's main characteristic is the use of Ruby 1.9.2 built from source.
@jakzal
jakzal / deploy.rb
Created October 25, 2011 11:41
parameters.yml configuration during capifony deployment for Symfony2
set :shared_files, [app_path + "/config/parameters.yml"]
namespace :symfony do
namespace :configure do
def shared_parameters_path
"#{shared_path}/#{app_path}/config/parameters.yml"
end
def app_parameters_path
"#{latest_release}/#{app_path}/config/parameters.yml"
@fzaninotto
fzaninotto / gist:1308714
Created October 24, 2011 10:11
Inserting data to several tables using Faker Populator, a custom formatter, and Propel
<?php
$faker = \Faker\Factory::create();
$populator = new \Faker\ORM\Propel\Populator($faker);
$populator->addEntity('Author', 10000);
$populator->addEntity('Book', 100000, $customColumnFormatters = array(
'ISBN' => function () use ($generator) { return $generator->randomNumber(13); },
));
$populator->addEntity('Review', 1000000);
$insertedPKs = $populator->execute();
@fzaninotto
fzaninotto / gist:1308697
Created October 24, 2011 09:58
Inserting data to several tables using Faker Populator and Propel
<?php
$faker = \Faker\Factory::create();
$populator = new \Faker\ORM\Propel\Populator($faker);
$populator->addEntity('Author', 10000);
$populator->addEntity('Book', 100000);
$populator->addEntity('Review', 1000000);
$insertedPKs = $populator->execute();
@fzaninotto
fzaninotto / gist:1308655
Created October 24, 2011 09:25
Inserting data to a database using Faker Populator and Propel
<?php
$faker = \Faker\Factory::create();
$populator = new \Faker\ORM\Propel\Populator($faker);
$populator->addEntity('Author', 100);
$insertedPKs = $populator->execute();
@fzaninotto
fzaninotto / gist:1308553
Created October 24, 2011 07:55
Inserting data to a database using Faker and Propel
<?php
$faker = \Faker\Factory::create();
$insertedPKs = array();
for ($i=0; $i < 100; $i++) {
$author = new Author();
$author->setFirstName($faker->firstName);
$author->setLastName($faker->lastName);
$author->setDateOfBirth($faker->date);
$author->setEmail($faker->email);
$author->save();
@fzaninotto
fzaninotto / gist:1308547
Created October 24, 2011 07:49
Inserting data to a database using Faker and PDO
<?php
$pdo = new PDO('mysql:host=hostname;dbname=defaultDbName', 'username', 'p@55w0rd');
$sql = 'INSERT INTO author (first_name, last_name, date_of_birth, email) VALUES (?, ?, ?, ?)';
$stmt = $pdo->prepare($sql);
$faker = \Faker\Factory::create();
$insertedPKs = array();
for ($i=0; $i < 100; $i++) {
$stmt->bindValue(1, $faker->firstName, PDO::PARAM_STR);
$stmt->bindValue(2, $faker->lastName, PDO::PARAM_STR);
$stmt->bindValue(1, $faker->date, PDO::PARAM_STR);