Skip to content

Instantly share code, notes, and snippets.

Avatar

Florian Klein docteurklein

View GitHub Profile
@weaverryan
weaverryan / wfValidatedFileNamer
Created Dec 4, 2010
Offers a way to save files as a cleaned, unique version of the original filename in symfony1
View wfValidatedFileNamer
<?php
/**
* Offers a way to save files as a cleaned, unique version of the original filename.
*
* Use this as the 'validated_file_class' option on sfValidatorFile.
*
* Bad characters are replaced by the replaceCharacter string. Unique filenames
* are created by appending an increasing -# to the end of the basename
* of the uploaded file.
@docteurklein
docteurklein / sub.sh
Created May 10, 2011
init submodules from a .gitmodules file
View sub.sh
#!/bin/bash
for cfg in `git config -f .gitmodules -l`
do
url=`echo $cfg | awk -F"submodule.*.url=" '{print $2}'`;
if [ -n "$url" ]; then
echo "git submodule add $url $path";
git submodule add $url $path;
@veloce
veloce / gist:1381140
Created Nov 20, 2011
post-merge hook to manage "dist" config files
View gist:1381140
#!/usr/bin/env sh
# File extension to check for changes
OBSERVE='dist'
# check if user configured mergetool
mergetool=`git config --get merge.tool`
if [[ -n "$mergetool" ]]; then
PROG=$mergetool
else
@docteurklein
docteurklein / extract.sh
Created Dec 2, 2011
extract non translated sentences in twig templates
View extract.sh
find . -type f -name "*.html.twig" | xargs perl -pi -e "s/>([^\s<{>].*?)</>{{ '\1'|trans }}</g"
@havvg
havvg / OrmigoBundle.php
Created May 2, 2012
Example StreamRegistry registering Gaufrette streams in Symfony2
View OrmigoBundle.php
<?php
namespace Ormigo\Bundle\OrmigoBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Ormigo\Bundle\OrmigoBundle\DependencyInjection\Compiler\RegisterStreamsPass;
/**
View ember-routes.md

Routing in Ember

In Ember, the application's state manager handles routing. Let's take a look at a simple example:

App.stateManager = Ember.StateManager.create({
  start: Ember.State.extend({
    index: Ember.State.extend({
      route: "/",
@merk
merk / AbstractInvoiceLineType.php
Created Jul 6, 2012
Symfony2 Form Polycollection for use with objects in an inheritance structure
View AbstractInvoiceLineType.php
<?php
// ...
class AbstractInvoiceLineType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
// ...
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active Sep 21, 2021
Useful PostgreSQL Queries and Commands
View postgres_queries_and_commands.sql
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@danguita
danguita / microsoft-ie-ova-images
Created Feb 24, 2013
Microsoft IE OVA images for VirtualBox (OSX)
View microsoft-ie-ova-images
# Microsoft IE OVA images from http://www.modern.ie/en-us/virtualization-tools
# VirtualBox for Mac:
http://virtualization.modern.ie/vhd/IEKitV1_Final/VirtualBox/OSX/IE6_WinXP.ova.zip
http://virtualization.modern.ie/vhd/IEKitV1_Final/VirtualBox/OSX/IE7_Vista.ova.zip
http://virtualization.modern.ie/vhd/IEKitV1_Final/VirtualBox/OSX/IE8_Win7.zip
http://virtualization.modern.ie/vhd/IEKitV1_Final/VirtualBox/OSX/IE9_Win7.zip
http://virtualization.modern.ie/vhd/IEKitV1_Final/VirtualBox/OSX/IE10_Win8.ova.zip
@callado4
callado4 / behat-phantomjs-webdriver.md
Last active Jan 24, 2021
Instructions on how to make behat (with mink) use the phantomjs webdriver to run headless browser tests
View behat-phantomjs-webdriver.md

Making behat use phantomjs for the tests

If you want to run it on phantomjs (a headless browser) you can add this profile to your behat.yml and you need phantomjs >= 1.8.0

phantomjs:
    extensions:
        Behat\MinkExtension\Extension:
            base_url: http://dev.local
            goutte: ~
            selenium2:
                wd_host: "http://localhost:8643/wd/hub"