Skip to content

Instantly share code, notes, and snippets.

@stof
stof / README.md
Last active February 16, 2022 14:58 — forked from davelandry/README.md
SVG Text Wrapping

Using d3plus.textwrap, SVG <text> elements can be broken into separate <tspan> lines, as HTML does with <div> elements. In this example, the first column shows normal wrapped text, the second column shows text that is resized to fill the available space, and the third column shows the default SVG behavior.

D3plus automatically detects if there is a <rect> or <circle> element placed directly before the <text> container element in DOM, and uses that element's shape and dimensions to wrap the text. If it can't find one, or that behavior needs to be overridden, they can manually be specified using .shape( ), .width( ), and .height( ).

Featured on D3plus.org

@stof
stof / input.scss
Created November 3, 2020 15:23
Generated by SassMeister.com.
$cmln-toc-entry-number-padding-right: 1rem;
$selector: "";
@for $i from 1 through 6 {
$selector: "#{$selector} ul li";
#{$selector} a .tocnumber { min-width: $cmln-toc-entry-number-padding-right + 0.25rem + 0.75rem * $i; }
}
@stof
stof / ComplexSqlBuilder.php
Created October 16, 2020 13:52
Building SQL queries using CTE with Doctrine DBAL
<?php
namespace Incenteev\WebBundle\Doctrine;
class ComplexSqlBuilder
{
/**
* @param string $mainSql
* @param string[] $cteQueries
* @param bool $recursive
@stof
stof / README.md
Last active January 21, 2020 09:51
Yarn weird bug installing node-pre-gyp

Steps to reproduce:

  1. take the package.json
  2. run yarn. This step produces a yarn.lock with the buggy content
  3. run yarn add temp
  4. run yarn remove temp. the package.json is now the same than the initial one, but the yarn.lock is the fixed one.
@stof
stof / CacheClearer.php
Created February 18, 2019 19:08
CacheClearer to allow running tests with Symfony in non-debug mode
<?php
namespace Incenteev\Tests\Util;
use Symfony\Component\Filesystem\Filesystem;
class CacheClearer
{
public function clearCache()
{
@stof
stof / upgrade_es_plugins.sh
Last active September 19, 2018 15:25
Reinstall ElasticSearch plugins easily
#!/usr/bin/env bash
# fail hard
set -o pipefail
# fail harder
set -eu
# update this list with the ES core plugins needing to be reinstalled.
PLUGINS="ingest-attachment analysis-icu"
@stof
stof / NewrelicExtension.php
Created July 3, 2018 14:21
Newrelic with CSP
<?php
namespace Incenteev\WebBundle\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class NewrelicExtension extends AbstractExtension
{
public function getFunctions()
@stof
stof / PasswordHashUpgrader.php
Last active October 8, 2018 08:10
FOSUserBundle password hashing upgrade on password changes
<?php
namespace Incenteev\WebBundle\Util;
use FOS\UserBundle\Model\UserInterface;
use FOS\UserBundle\Util\PasswordUpdaterInterface;
use Incenteev\WebBundle\Entity\User;
class PasswordHashUpgrader implements PasswordUpdaterInterface
{
<?php
class Bar
{
public function doSth()
{
echo 'sth';
}
}
@stof
stof / TwigRenderer.php
Last active September 16, 2020 07:46
Rendering twig blocks directly from outside a twig render call, for email purpose
<?php
namespace Incenteev\MailerBundle\Mailer;
class TwigRenderer implements RendererInterface
{
private $twig;
private $styleInliner;
/**