Skip to content

Instantly share code, notes, and snippets.

View craigmarvelley's full-sized avatar

Craig Marvelley craigmarvelley

View GitHub Profile
@cowlby
cowlby / collection_widget.twig
Created October 17, 2011 23:32
Customizing form collections in Symfony2
{% block collection_widget %}
{% spaceless %}
<div class="collection">
{% if prototype is defined %}
{% set attr = attr|merge({'data-prototype': block('collection_item_widget') }) %}
{% endif %}
<div {{ block('widget_container_attributes') }}>
{{ form_errors(form) }}
<ul>
{% for rows in form %}
@beberlei
beberlei / MyWebTestCase.php
Created September 17, 2011 12:14
Easily Inject authenticated Symfony User into functional test
<?php
use Liip\FunctionalTestBundle\Test\WebTestCase;
use Symfony\Component\HttpKernel\Profiler\Profiler;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @group functional
*/
@shaneog
shaneog / update_acl.rb
Created August 30, 2011 16:20
Capifony Task to Set ACLs on Symfony2 app/cache and app/logs directories as per http://symfony.com/doc/current/book/installation.html
# Change ACL on the app/logs and app/cache directories
after 'deploy', 'deploy:update_acl'
# This is a custom task to set the ACL on the app/logs and app/cache directories
namespace :deploy do
task :update_acl, :roles => :app do
shared_dirs = [
app_path + "/logs",
@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite