Skip to content

Instantly share code, notes, and snippets.

View SebCorbin's full-sized avatar

Sébastien Corbin SebCorbin

View GitHub Profile
@SebCorbin
SebCorbin / mymodule.js
Created March 6, 2012 21:53
Using highcharts with Drupal 7
(function ($) {
Drupal.behaviors.mymodule_charts = {
attach:function () {
if (Drupal.settings.mymodule.charts) {
for (var chart in Drupal.settings.mymodule.charts) {
new Highcharts.Chart(Drupal.settings.mymodule.charts[chart]);
}
}
}
};
@SebCorbin
SebCorbin / mymodule.php
Created May 12, 2012 22:53
Send pending approval mails to all users who have the 'administer users' permission
<?php
/**
* Implements hook_mail_alter().
*
* Also send pending approval mails to users who have
* the 'administer users' permission
*
* @see _user_mail_notify()
*/
@SebCorbin
SebCorbin / gist:5344223
Created April 9, 2013 09:06
Drupal: quickly generate an image file
<?php
$response = drupal_http_request('http://placekitten.com/g/' . $width . '/' . $height);
if ($response->code !== 200) {
// If cats are sleeping, take another image generator
$response = drupal_http_request('http://lorempixel.com/g/' . $width . '/' . $height);
}
$destination = 'public://miaou' . $width . 'x' . $height . '.png';
$file = file_save_data($response->data, $destination, FILE_EXISTS_REPLACE);
@SebCorbin
SebCorbin / Enregistrer la selection en SVG.jsx
Created April 7, 2015 14:25
Illustrator script - Save selection as SVG
/*
* Export selection to SVG - export_selection_as_SVG
* (Adapted from Layers to SVG 0.1 - export_selection_as_SVG.jsx, by Rhys van der Waerden)
*
* @author SebCorbin
*/
// Variables
var ignoreHidden = true,
svgExportOptions = (function () {
@SebCorbin
SebCorbin / block.tpl.twig
Last active July 8, 2021 09:50
Drupal Bootstrap theme main templates converted to Twig
<section id="{{ block_html_id }}" class="{{ classes }} clearfix"{{ attributes }}>
{{ title_prefix }}
{% if title %}
<h2{{ title_attributes }}>{{ title }}</h2>
{% endif %}
{{ title_suffix }}
{{ content }}
</section>
<?php
/**
* Implements hook_page_delivery_callback_alter().
*/
function fixtrail_page_delivery_callback_alter(&$callback) {
$current_path = current_path();
// Only work on normal pages, not ajax nor admin pages.
if ($callback != 'drupal_deliver_html_page' || path_is_admin($current_path)) {
return;
@SebCorbin
SebCorbin / FormController.php
Created December 7, 2016 15:14
PoneyBundle - An example of contact form for poneys
<?php
// PoneyBundle/Controller/FormController.php
namespace PoneyBundle\Controller;
use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType;
use EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
@SebCorbin
SebCorbin / .gitconfig
Last active May 27, 2020 20:43 — forked from alikins/.gitattributes
po/pot file attributes for textconf and diff (ie, make git diff on gettext files less useless)
# From http://stackoverflow.com/questions/2006351/gettext-po-files-under-version-control/11291001#11291001
[diff "msgcat"]
textconv = msgcat --no-location --no-wrap --sort-output
"""
Générateur de jours ouvrés français en python
"""
def easter_date(year):
"""
Calcule la date du jour de Pâques d'une année donnée
Voir https://github.com/dateutil/dateutil/blob/master/dateutil/easter.py
:return: datetime
@SebCorbin
SebCorbin / .pdbrc.py
Created April 29, 2020 13:41
Pdbpp configuration
"""
This is a custom configuration file for pdb++, put it in home dir.
"""
import readline
import pdb
class Config(pdb.DefaultConfig):
filename_color = pdb.Color.lightgray
use_terminal256formatter = False