Skip to content

Instantly share code, notes, and snippets.

View terox's full-sized avatar
🎯
Focusing

David Pérez Terol terox

🎯
Focusing
View GitHub Profile
@extolabs
extolabs / Form.php
Created May 12, 2011 16:19
Form Errors Symfony
private function getAllFormErrors($children, $template = true) {
foreach ($children as $child) {
if ($child->hasErrors()) {
$vars = $child->createView()->getVars();
$errors = $child->getErrors();
foreach ($errors as $error) {
$this->allErrors[$vars["name"]][] = $this->convertFormErrorObjToString($error);
}
}
@alkema
alkema / deploy.rb
Created July 9, 2011 20:01
Capistrano task for a Node.js app with github Forever and NPM.
set :application, "appname"
set :deploy_to, "/var/www"
set :scm, :git
set :repository, "git@github.com:user/app.git"
default_run_options[:pty] = true
set :user, "www-data"
set :domain, "foo.tld"
set :normalize_asset_timestamps, false
@lancejpollard
lancejpollard / node-folder-structure-options.md
Created November 28, 2011 01:50
What is your folder-structure preference for a large-scale Node.js project?

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin
@brtriver
brtriver / BasicAuthControllerProvider.php
Created February 4, 2012 20:36
Simple Basic Auth Controller for Silex.
<?php
namespace Silex\Provider;
use Silex\Application;
use Silex\SilexEvents;
use Silex\ControllerProviderInterface;
use Silex\ControllerCollection;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@cowboy
cowboy / 1.before.js
Created June 25, 2012 17:46
grunt: an example of building task targets dynamically
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
min: {
ariaAccessibility: {
src: ['src/javascripts/jquery.selectBoxIt.ariaAccessibility.js'],
dest: 'src/javascripts/jquery.selectBoxIt.ariaAccessibility.min.js'
},
@nikcub
nikcub / README.md
Created October 4, 2012 13:06
Facebook PHP Source Code from August 2007
@bjo3rnf
bjo3rnf / EntityHiddenType.php
Last active November 19, 2021 17:19
Hidden field for Symfony2 entities
<?php
namespace Dpn\ToolsBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Dpn\ToolsBundle\Form\DataTransformer\EntityToIdTransformer;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Doctrine\Common\Persistence\ObjectManager;
@danvbe
danvbe / 1-Explanations.md
Last active April 21, 2023 15:39
A way to integrate FosUserBundle and HWIOAuthBundle

I have managed to install this… and make it work. I implemented it for Facebook and Google, but you can extend it. My solution it is mostly as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:

  • the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
  • set the service for oauth_user_provider in the security.yml with your custom created service

Here are the steps:

  1. Routing. In routing.yml I have added all the routes for both bundles.
  2. Configuration. I have set the config.yml mostly as it is presented in the HWIOAuthBundle.
  3. Security. I have set the security.yml mostly as it is presented in the HWIOAuthBundle (though my routes are using /login pattern, not /connect). Also, the oauth_user_provider is set for my custom service.
@cecilemuller
cecilemuller / get_combinations.php
Created February 1, 2013 03:13
PHP: Get all combinations of multiple arrays (preserves keys)
<?php
function get_combinations($arrays) {
$result = array(array());
foreach ($arrays as $property => $property_values) {
$tmp = array();
foreach ($result as $result_item) {
foreach ($property_values as $property_value) {
$tmp[] = array_merge($result_item, array($property => $property_value));
}