Skip to content

Instantly share code, notes, and snippets.

View dunglas's full-sized avatar

Kévin Dunglas dunglas

View GitHub Profile
@dunglas
dunglas / sfFacebookNewDoctrineGuardAdapter.class.php
Created March 8, 2011 08:55
sfFacebookConnectPlugin Adapter for recents sfDoctrineGuardPlugin versions.
<?php
/**
*
* @package sfFacebookConnectPlugin
* @author Kévin Dunglas <dunglas@gmail.com>
* @author Fabrice Bernhard
*
*/
class sfFacebookNewDoctrineGuardAdapter extends sfFacebookGuardAdapter {
@dunglas
dunglas / invite-friends.js
Last active May 23, 2016 20:56
Invite all your Facebook friends (v3)
// Scroll to the bottom of the friend list and type the following line in your console
// For checkboxes (e.g. invite to an event)
var c = document.querySelectorAll("a[role='checkbox']"); for (var i = 0; i < c.length; i++) c[i].click();
// For invite buttons (e.g. invite to like a page)
var c = document.querySelectorAll(".uiButton._1sm"); for (var i = 0; i < c.length; i++) c[i].click();
@dunglas
dunglas / sleep-AuthController.php
Created November 22, 2012 20:24
Un sleep inutile
// Prestashop 1.5.2, controllers/front/AuthController.php, line 278
$customer = new Customer();
$authentication = $customer->getByEmail(trim($email), trim($passwd));
if (!$authentication || !$customer->id)
{
// Handle brute force attacks
sleep(1);
$this->errors[] = Tools::displayError('Authentication failed');
}
@dunglas
dunglas / config.yml
Last active December 10, 2015 06:58
Symfony's Assetic configuration to compile CoffeeScript files.
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ DunglasChaplinDemoBundle ]
# java: /usr/bin/java
filters:
cssrewrite: ~
coffee:
bin: %coffee_path%
parameters:
# ...
coffee_path: /usr/local/share/npm/bin/coffee
node_path: /usr/local/bin/node
@dunglas
dunglas / DefaultController.php
Last active December 10, 2015 06:58
Controller to load the SPA
<?php
// Part of the Dunglas' Symfony 2 / Chaplin.js tutorial
// http://dunglas.fr/2012/12/utiliser-chaplin-js-et-backbone-js-avec-symfony-2-installation-et-configuration/
namespace Dunglas\ChaplinDemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
@dunglas
dunglas / index.html.twig
Last active December 10, 2015 07:38
Chaplin.js boilerplate for Symfony (Twig)
{#
Part of the Dunglas' Symfony 2 / Chaplin.js tutorial
http://dunglas.fr/2012/12/utiliser-chaplin-js-et-backbone-js-avec-symfony-2-installation-et-configuration/
#}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Chaplin Boilerplate Application</title>
<style>
@dunglas
dunglas / hello_world_application.coffee
Last active December 10, 2015 09:08
Use a root option for the router
# Part of the Dunglas' Symfony 2 / Chaplin.js tutorial
# http://dunglas.fr/2012/12/utiliser-chaplin-js-et-backbone-js-avec-symfony-2-installation-et-configuration/
define [
'chaplin'
'views/layout'
'routes'
], (Chaplin, Layout, routes) ->
'use strict'
@dunglas
dunglas / config.yml
Created January 8, 2013 18:08
FOSRestBundle config
# Part of the Dunglas' Symfony 2 / Chaplin.js tutorial
# http://dunglas.fr/2012/12/utiliser-chaplin-js-et-backbone-js-avec-symfony-2-installation-et-configuration/
fos_rest:
routing_loader:
default_format: json
body_listener: true
@dunglas
dunglas / bench.php
Last active August 29, 2015 14:05
hash_equals benchmark
<?php
/**
* Constant-time comparision length leak benchmark.
* Inspirated by https://gist.github.com/yohgaki/ede544f290c6cf9fa90d
*
* @author Kévin Dunglas
*/
$knownSize = 1024;
$userShortSize = 512;