Skip to content

Instantly share code, notes, and snippets.

@rccc
rccc / gist:db5a3bc9fe03b607060d
Created May 16, 2014 08:08
SF2 - check if user is connected
if (!$this->get('security.context')->isGranted('ROLE_USER'))
{
...
}
@rccc
rccc / symfony_run_command
Last active August 29, 2015 14:02
run command
$command = new CustomerSearchAdvertComparisonCommand();
$command->setContainer($event->getContainer());
$input = new ArgvInput(array('bvm:customer_search:advert:compare ', $entity->getId(), $search->getId()));
$output = new BufferedOutput();
$result = $command->run($input, $output);

Sélecteurs

Balises

console.time('jQuery');

// jQuery
var divs = $('div');

Navigation

Enfants

// jQuery
jQuery('#my-id').children()

// vanilla
// jQuery
$('body').append($('<p/>'))
// Vanilla
document.body.appendChild(document.createElement('p'))

$("#container").append("<p>more content</p>");

document.getElementById("container").innerHTML += "<p>more content</p>";
// jQuery
$(document).ready(function() {
  // code
})

// Vanilla
document.addEventListener('DOMContentLoaded', function() {
 // code

Scope chain

  • Quand le code javascript est executé, un contexte d'execution est créé.
  • Plusieurs contextes d'execution peuvent être empilés au cours de l'execution d'un programme.
  • Le contexte d'execution peut être representé comme un object :
function add(num1, num2){
@rccc
rccc / ajax.md
Last active August 29, 2015 14:10

AJAX

GET

// jQuery
$.get('//example.com', function (data) {
  // code
})
@rccc
rccc / d3.js responsive svg
Last active August 29, 2015 14:14
d3.js responsive svg
var div = d3.select("#display");
div.append("svg:svg")
.attr("width", "100%")
.attr("height", "100%")
.attr("viewBox", "0 0 800 600")
.append("svg:circle")
.attr("cx", 400)
.attr("cy", 300)
.attr("r", 250)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.