Skip to content

Instantly share code, notes, and snippets.

View pounard's full-sized avatar
💭
What's happening?

Pierre pounard

💭
What's happening?
View GitHub Profile
<?php
namespace Drupal\my_module\Plugins\Blocks;
/**
* @Plugin(
* type="menu_block",
* title="Menu Block",
* description="A block for displaying system or user generated menus."
* )
@pounard
pounard / moche.js
Last active August 29, 2015 14:12
/*jslint browser: true, plusplus: true, indent: 2 */
/*global Node, console, Blob */
/**
* Et tu pleures. Et tu pleures. Et tu pleures. Mais ça marche.
*
* But how the fuck will I make this work?
* - Step 1: Open your firebug (or other) console
* - Step 2: Paste this code into it
* - Step 3: Click "Execute" (or maybe "Run")
* - Step 4: If everything went OK your browser will download the file
/**
* abs(Nombre number) : Nombre result
* Renvoie la valeur absolue du nombre number.
* Le nombre dont la valeur absolue sera calculée.
* La valeur absolue du nombre.
*
* @level 1
* @cores 1
*
@pounard
pounard / gist:7b23c4150704f2657b22
Last active August 29, 2015 14:14
leek-runtime-en.js
/**
* abs(Number number) : Number result
* Returns the absolute value of given number.
* A number.
* Given number's absolute value.
*
* @level 1
* @cores 1
*
@pounard
pounard / gist:6f620cc38063d1a652d1
Created February 3, 2015 11:12
mimemail-7.x-1.0-beta1 -mailsystem
diff -urN mimemail.orig//mimemail.info mimemail//mimemail.info
--- mimemail.orig//mimemail.info 2015-01-12 12:06:10.000000000 +0100
+++ mimemail//mimemail.info 2015-01-12 12:08:23.000000000 +0100
@@ -1,6 +1,5 @@
name = Mime Mail
description = Send MIME-encoded emails with embedded images and attachments.
-dependencies[] = mailsystem
package = Mail
core = 7.x
@pounard
pounard / advanced-forum-is-stupid.php
Last active August 29, 2015 14:15
Those lines may save your life whenever you use the advanced_forum module.
/**
* Implements hook_process().
*/
function MYTHEMEORMODULE_process(&$variables, $hook) {
// Seems legit.
// @see laborange2_theme_registry_alter().
if (false === strpos($hook, 'advanced_forum')) {
// This one is a stupid variable mis-use and typo from advanced_forum.
if (!empty($variables['theme_hook_suggestion']) && false !== strpos($variables['theme_hook_suggestion'], 'advanced_forum')) {
// Do not override the 'theme_hook_suggestion' other than advanced
$mockList = [
[
'name' => "Sa maman",
'firstname' => 'Josianne',
'lastname' => 'Balasko',
],
[
'name' => "Des ours",
'firstname' => 'Jean',
'lastname' => 'Rochefort',
$conf['mail_system'] = ['default-system' => 'NetSmtp_MailSystemProxy'];
$conf['netsmtp_proxy'] = ['default' => 'MimeMailSystem'];
$conf['netsmtp_catch'] = [
'[email protected]',
'[email protected]',
// ...
];
$conf['netsmtp_debug_trace'] = true;
$conf['netsmtp_debug_mime'] = true;
$conf['netsmtp'] = [
@pounard
pounard / prevent-double-click.js
Created May 7, 2015 09:46
Tiny JS code (jQuery, sorry guys) - that prevents double click on target forms.
// Prevent double click in some forms.
(function(jQuery) {
"use strict";
Drupal.behaviors.fixDoubleClick = {
attach: function (context) {
var k, selectors = [
"#comment-form"
// Add here forms with problems.
];
for (k in selectors) {
@pounard
pounard / fucking-drupal-version.php
Created May 29, 2015 14:36
Restores all modules version to their latest number (useful if you did a wrong UPDATE in {system} table).
require_once DRUPAL_ROOT . '/includes/update.inc';
$modules = db_query("SELECT name, 1 FROM {system} WHERE type = 'module'")->fetchAllKeyed();
foreach (array_keys($modules) as $key) {
module_load_install($key);
$updates = [];
// From module.inc/update.inc.
$regexp = '/^' . $key . '_update_(?P<version>\d+)$/';
$functions = get_defined_functions();
foreach (preg_grep('/_\d+$/', $functions['user']) as $function) {
$matches = [];