Skip to content

Instantly share code, notes, and snippets.

View dunglas's full-sized avatar

Kévin Dunglas dunglas

View GitHub Profile
@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 / hash.php
Last active January 11, 2016 16:41
public static function generateHash($value, $namespace = '')
{
$hash = hash_init('sha256');
$queue = array(array($namespace => $value));
for ($i = 0; isset($queue[$i]); ++$i) {
foreach ($queue[$i] as $k => $v) {
if (is_object($v)) {
hash_update($hash, $k.'=>'.spl_object_hash($v).',';
} elseif (is_array($v)) {
$queue[] = $v;
@dunglas
dunglas / routing.yml
Created March 8, 2016 12:23
YAML Route for DunglasActionBundle
foo:
path: /foo/{bar}
defaults: { _controller: 'action.Path\To\Your\Action' }
@dunglas
dunglas / access_special_key.php
Created April 21, 2016 08:47
Access a PHP special key /cc @vincentchalamon
$c = (object) ['@context' => 'foo'];
var_dump($c);
/*
php shell code:1:
class stdClass#1 (1) {
public $@context =>
string(3) "foo"
}
*/
$key = '@context';
@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();

Keybase proof

I hereby claim:

  • I am dunglas on github.
  • I am dunglas (https://keybase.io/dunglas) on keybase.
  • I have a public key whose fingerprint is 31D2 33ED 1FBA 7DAF F033 90EE 4D04 EBEF 06AA F3A6

To claim this, I am signing this object:

You are about to deploy the following services:
- api-platform-website/default/20161019t000544 (from [/Users/dunglas/workspace/react-redux-universal-hot-example/app.yaml])
Deploying to URL: [https://api-platform-website.appspot.com]
Do you want to continue (Y/n)? y
If this is your first deployment, this may take a while...done.
Beginning deployment of service [default]...
WARNING: Deployment of App Engine Flexible Environment apps is currently in Beta
@dunglas
dunglas / DataProvider.php
Last active January 9, 2017 11:11
FOSElastica paginator for API Platform v1 Raw
<?php
namespace Acme\ApiPlatform\FOSElastica;
use Dunglas\ApiBundle\Api\ResourceInterface;
use Dunglas\ApiBundle\Model\DataProviderInterface;
use Elastica\Query;
use FOS\ElasticaBundle\Finder\PaginatedFinderInterface;
use Symfony\Component\HttpFoundation\Request;
new MutationObserver(mutation => {
for (let lemming of document.querySelectorAll('img[alt="lemming tombant"]')) {
lemming.dispatchEvent(new Event('mouseover', { bubbles: true }));
}
}).observe(document, {childList: true, subtree: true});