Skip to content

Instantly share code, notes, and snippets.

View yuriteixeira's full-sized avatar

Yuri Teixeira yuriteixeira

View GitHub Profile
@yuriteixeira
yuriteixeira / doctrine_multiple_insert_fail.php
Created January 24, 2012 13:23
Should execute multiple inserts (400 queries with 100 rows each, but executing regular 4000 queries instead)
/**
* @Route("/sandbox/insert-test")
* @Template()
*/
public function insertTestAction() {
$em = $this->getDoctrine()->getEntityManager();
$datetime = new \DateTime();
$qtty = 4000;
@yuriteixeira
yuriteixeira / gist:1827790
Created February 14, 2012 16:07
SF2, Doctrine and Caching
/**
* @param string $blockSlug
* @return \Rocket\BraPrintBundle\Entity\CmsBlock
*/
public function getBlock($blockSlug) {
$result = '';
$repo = $this->getEntityManager()->getRepository('RocketBraPrintBundle:CmsBlock');
$item = $repo->findOneBySlug($blockSlug);
if ($item instanceof CmsBlock) {
1) Criar uma entidade chamada StaticFile, com os atributos:
- original_name
- content_type
- slug
- size
2) Alterar a entidade CmsBlock, adicionando o atributo:
- is_published
3) Criar um novo botão no editor TinyMCE, que chamará um popup de upload de imagens
@yuriteixeira
yuriteixeira / BehatTest.php
Created December 16, 2012 20:16 — forked from jakzal/BehatTest.php
A quick and dirty PHPUnit test case that runs behat, making code coverage reports being possible!
<?php
use Symfony\Component\Console\Input\ArrayInput;
use Behat\Behat\Console\BehatApplication;
use Symfony\Component\Console\Output\ConsoleOutput;
class BehatTest extends \PHPUnit_Framework_TestCase
{
public function testThatBehatScenariosMeetAcceptanceCriteria()
{
@yuriteixeira
yuriteixeira / gist:5191784
Created March 18, 2013 23:09
fix problem on doctrine odm
protected function loadConnections(array $connections, ContainerBuilder $container)
{
$cons = array();
foreach ($connections as $name => $connection) {
// Define an event manager for this connection
$eventManagerId = sprintf('doctrine_mongodb.odm.%s_connection.event_manager', $name);
$container->setDefinition($eventManagerId, new DefinitionDecorator('doctrine_mongodb.odm.connection.event_manager'));
$configServiceName = sprintf('doctrine_mongodb.odm.%s_configuration', $name);
@yuriteixeira
yuriteixeira / filebot-amc.sh
Last active December 17, 2015 11:49
Filebot AMC (Automated Media Center) Helper
#!/bin/bash
if [ $1 ] && [ $1 == '-h' ]
then
echo ""
echo "Welcome to Filebot AMC (Automated Media Center) Script."
echo ""
echo "Usage: filebot-amc.sh [torrent_name] [/path/to/torrent] [/path/to/media] [/path/to/log]"
echo ""
echo "NOTES: "
@yuriteixeira
yuriteixeira / boot2docker-vbox-foldershare-mac.sh
Last active August 29, 2015 14:07
Boot2Docker + Virtual Box Additions (will make volume share work with Mac OS X)
#!/bin/bash
boot2docker down
wget http://static.dockerfiles.io/boot2docker-v1.2.0-virtualbox-guest-additions-v4.3.14.iso
mv ~/.boot2docker/boot2docker.iso ~/.boot2docker/boot2docker.iso.backup
cp boot2docker-v1.2.0-virtualbox-guest-additions-v4.3.14.iso ~/.boot2docker/boot2docker.iso
@yuriteixeira
yuriteixeira / go-oop-inherit.go
Last active August 29, 2015 14:17
OOP and Golang: "Inheritance"
package main
import "fmt"
type Foo struct {
what string
howMany int
}
type Bar struct {
@yuriteixeira
yuriteixeira / tdd.sh
Created March 20, 2015 17:30
TDD Made Easy - Run tests when the files change
# TDD
function tdd {
pathToTestRunner=$1
filesToWatch=$2
if [[ -z $pathToTestRunner ]]
then
pathToTestRunner="vendor/bin/phpunit"
fi
@yuriteixeira
yuriteixeira / skyscanner.php
Last active August 29, 2015 14:21
Generate skyscanner search urls. To open then, copy and paste the result on openlist chrome extension (https://chrome.google.com/webstore/detail/openlist/nkpjembldfckmdchbdiclhfedcngbgnl?hl=en), like you see here: http://i.imgur.com/oCfY2Wy.jpg
<?php
// Usage :
// php fly.php <start_date> <trip_interval> <variance> <from> <to>
//
// Eg: A 7 day trip from VIX to STOC, 30 days of variance
// php fly.php 2015-07-01 30 "+7 day" vix stoc
$start = new \DateTime("{$argv[1]}");
$variance = "+{$argv[2]} day";