Recent Posts
-
September 08, 2024
C'est quoi once() et context dans le Javascript Drupal
Si nous voulons ajouter un comportement à un élément du DOM dans Drupal, il peut être utile de comprendre comment once() et context fonctionnent.Prenons un exemple où un bloc affiche un bouton et que du Javascript ajoute un comportement (event han...
-
August 16, 2024
Limiter la taille d'une base de données dans Drupal
Si vous avez un site Drupal en production et que vos tables de base données débutant par cache_ sont trop volumineuses, cet article examinera comment vous pouvez limiter leur taille.Commençons par par regarder les tables de cache sur un site Drupa...
-
June 19, 2024
GTM et les cookies sur les sous-domaines
C’est quoi GTM?Historiquement, pour associer un site web avec des service externes tels Google Analytics, il suffisait d’ouvrir un compte sur ce service et de coller un peu de JavaScipt sur votre site web. Ces bouts de JavaScript sont appelés des ...
-
November 15, 2023
Setting up encrypted custom domain (apex and www) on GitHub pages
GitHub Pages is a simple, free way to host a static website, either plain HTML, or generated by a static site generator such as Jekyll.GitHub Pages allows you to use a custom domain, such as example.com or www.example.com, or both.In this post we ...
-
June 16, 2023
Is it worth the hassle to convert currencies with a limit price, or is it better to use a spot price instead?
I do a lot of business in the U.S. but I live in Canada. I therefore need to convert funds from USD to CAD on a regular basis.Wise allows you to convert funds either immediately, or by “auto convert” based on a “desired rate”.For example, if the U...
-
March 28, 2023
Using Jenkins' Plot plugin to graph data
Using Jenkins to run periodic tasks, we might end up with useful data we’d like to see over time.If you have Jenkins running, you can create an example job called “plot test”, add an “execute shell” build step, with the following code which prints...
-
April 22, 2022
Customizing TinyMCE on Mediawiki
In this post we will look at how to customize the TinyMCE toolbar for Mediawiki, by making custom toolsets, and we will look at the challenge of figuring out machine names of tools you would like to use.To follow along, if you have Docker installe...
-
April 21, 2022
Alpine and Docker, a perfect fit
Working with a new M1-powered MacBook has had a big effect on my Docker workflows.On the one hand, containers properly configured for the ARM achitecture, used by M1, are very fast, as discussed in Docker PHP on the M1 chip, example with Static An...
-
April 19, 2022
Verifying telephone numbers in Drupal
When allowing users to input phone numbers in Drupal, you might want to make sure that they actually have access to the phone number they are using, rather than being allowed to input any random phone number.In practice, when a user claims to have...
-
March 25, 2022
PHP and Apache (or Nginx) in separate Docker containers using Docker Compose
In many cases, PHP and Apache are run in the same container and based on a single image.For example, the PHP image has tags which combine Apache and Debian; Similarly for the Drupal CMS image.If you are currently managing a project which uses php:...
-
March 24, 2022
Installing Docker for Windows (not for the faint of heart)
Here is how to use Docker Desktop for Windows. This has been tested on a Windows 10 Pro (Supposedly if you’re using Windows 10 Home, you’re out of luck) HP EliteBook with 16 Gb or RAM. (I have found that on machines with less RAM certain errors ca...
-
February 27, 2022
Translating a Drupal user interface (PHP and Javascript): a workflow
So you find yourself, as one does, building a complete user interface with PHP and Javascript for Drupal 9; and you’d like to delegate the translation of the front-end to a non-developer. (You want the client to be empowered to change the UI strin...
-
February 07, 2022
Altering a list view in drupal, using an example with Webform
In some cases administrative lists are actually views using the core Views module, as is the case with /admin/content (which can be modified using the Views interface at /admin/structure/views/view/content). These are quite easy to modify in a dev...
-
January 27, 2022
In a spreadsheet, do not reference a cell calculated using UNIQUE() or FILTER()
If you are using Google Sheet’s =UNIQUE() or =FILTER() functions (or both) to generate values in cells, you should never reference those cells directly.ExampleIf you have these cells in sh1: A B C 1 ...
-
November 17, 2021
Docker PHP on the M1 chip, example with Static Analysis on Drupal: 9 times faster
In 2020, Apple unveiled a new chip, M1, which uses a different architecture than the Intel chips widely used in servers and laptops.Docker calls the intel architecture “linux/amd64”, and the M1 architecture “linux/arm64” (can also be linux/arm64/v...
-
July 19, 2021
The Revenge of Simple
All public websites work the same way; clients request a URL and, as a response, get some standard HTML, CSS, JavaScript and image files.If you are building the next Tinder or Reddit or Yelp, things are a bit more complex. You need a database, sec...
-
June 10, 2021
Weighted average is bad; weighted average from multiple sources is worse
I’ve already written about why I hate the “weighted average” accounting method for foreign funds in Producing an expense report in foreign funds using the weighted average method (May 12, 2020).In this post I’ll take a hypothetical example of havi...
-
January 29, 2021
hook_update_N(), a powerful and dangerous tool to use sparingly
What is hook_update_N()?Let’s say you are developing a Drupal module (custom or contrib) which tracks how many visitors landed on specific node pages, version 1 of your code might track visitors by nid (node id) in the database using a table like ...
-
January 20, 2021
Adding continuous integration (CI) to your workflow
This post is aimed at web development teams and is not tied to a specific technology. We will aim to not get more technical than is needed, but rather to explore what Continuous integration (CI) is, and how it can help save teams money within a mo...
-
November 05, 2020
Traccar fleet management software evaluation
I found myself in need of managing a fleet of 4 vehicles with a plan to increase to over 20 vehicles in the coming years: track milage cross-reference fuel usage with milage I want my system to be open-source and self-hosted I want my system t...
-
May 12, 2020
Producing an expense report in foreign funds using the weighted average method
Next time you find yourself working on a project in, say, Haiti, and receiving funding from, say, the Canadian Government, keep in mind that exchange rates can vary wildly, and some funders can request specific methods for reporting expenses. In t...
-
April 22, 2020
Deploying Drupal to Kubernetes, no previous knowledge required
Kubernetes is a way of deploying resilient, scalable applications to the cloud. Resilient because Kubernetes is designed to recover if something goes wrong. Scalable because with Kubernetes, your application is not linked to a single virtual mac...
-
April 09, 2020
On the importance of the base currency of a balance sheet
First I must warn you that I am by no means an accountant; but I would like to share a particularity of reporting accounts in a currency different from the base currency. I’ll give an example with an organization that reports its balance sheet in ...
-
December 03, 2019
Écouter des fichiers de musique de votre Mac sur votre téléphone Android
Cet article décrit une technique pour écouter des fichiers de musique (m4a, mp3…) que vous avez sur votre Mac, et que vous aimeriez écouter sur votre téléphone Android, sans passer par un compte cloud (Google Play, etc.). Cette technique est très ...
-
October 16, 2019
Start unit testing your Drupal and other PHP code today
Unit tests are the fastest, most reliable kinds of tests: they confirm that the smallest units of your code, i.e. class methods, work as expected.Unit tests do not require a full environment with a database and external libraries; this makes unit ...
-
June 01, 2019
Filters on Blended Data in Google Data Studio
Google Data Studio is a free service which allows you to create dashboards based on multiple data sources, especially Google-centric ones but also databases. The data can be filtered by date and other so-called dimensions.Previous knowledgeThis ar...
-
April 10, 2019
Quickbooks usability issues
I’ve recently had to start using Quickbooks because it is required by my accountant to get verified financial statements for a nonprofit on whose board I serve. Here is a short description of my experience to date… I opened a company using the 30...
-
April 07, 2019
An approach to automating Drupal accessibility tests
Accessibility tests can be automated to a degree, but not completely; to succeed at accessibility, it needs to be a mindset shared by developers, UX and front-end folks, business people and other stakeholders. In this article, we will attempt to r...
-
March 14, 2019
Debug outgoing emails with Mailhog, a dummy mailserver with a GUI
Often, during local Drupal development (or if we’re really unlucky, in production), we get the dreaded message, “Unable to send e-mail. Contact the site administrator if the problem persists.”This can make it hard to debug anything email-related d...
-
March 04, 2019
What if accounting worked like software development? Command-line, double-entry accounting for agencies
I’ve always fled my accounting responsibilities, or did the bare minimum, using inadequate tools like spreadsheets, only to be caught up yearly at tax time having to apologize to my dumbfounded accountant.My situation at Dcycle is typical: multipl...
-
February 20, 2019
Run long-lived processes on a remote server while you are logged out, using the Screen utility
IntroductionConsider the following scenario: you’re on a long-distance multi-day bike ride, you have your laptop with you and you need to run a long process on a remote Ubuntu server, something like importing a huge database, which might take upwa...
-
October 27, 2018
Local development using Docker Compose and HTTPS
This article discusses how to use HTTPS for local development if you use Docker and Docker Compose to develop Drupal 7 or Drupal 8 (indeed any other platform as well) projects. We’re assuming you already have a technique to deploy your code to pro...
-
October 05, 2018
HTTPS on Acquia stage environments with LetsEncrypt, semi-automated
I recently ran into a series of weird issues on my Acquia production environment which I traced back to some code I deployed which depended on my site being served securely using HTTPS.Acquia Staging environments don’t use HTTPS by default and req...
-
April 07, 2018
Fast-track local Drupal 8 core patch development and testing
The process documented process for setting up a local environment and running tests locally is, in my opinion, so complex that it can be a barrier to even determined developers.For those wishing to locally test and develop core patches, I think it...
-
February 25, 2018
Getting around Replace NewToner on Dell E310DW
Getting around “Replace NewToner” on Dell E310DWThe Dell E310DW prevents you from printing if it thinks the toner is low. Of course, the toner is fine, it’s just planned obsolescence.There is a way around this: Go to http://dellfa608a.local./gene...
-
February 23, 2018
Microsoft Mozaik is unusable
My school board, Marguerite-Bourgeoys, sent my wife and myself an email asking us to re-register our kids for the following year using Microsoft Mozaik software.A link is provided to the Microsoft Mozaik portal.My wife tried registering several ti...
-
January 24, 2018
Caching a Drupal 8 REST resource
Here are a few things I learned about caching for REST resources.There are probably better ways to accomplish this, but here is what works for me.Let’s say we have a REST resource that looks something like this in .../my_module/src/Plugin/rest/res...
-
December 18, 2017
Migrating Webforms from Drupal 7 to Drupal 8
I recently needed to port hundreds of Drupal 7 webforms with thousands of submissions from Drupal 7 to Drupal 8.My requirements were: Node ids need to remain the same Webforms need to be treated as data: they should be ignored by config export a...
-
October 06, 2017
Deploying Letsencrypt with Docker-Compose
Last week I wrote about setting up a reverse-proxy to serve a number any number of Docker containers via https.In order for this technique to work with Docker-Compose, we need to add a network to the Docker-Compose container.PremiseLet’s say you h...
-
October 03, 2017
Letsencrypt HTTPS for Drupal on Docker
This article is about serving your Drupal Docker container, and/or any other container, via https with a valid Let’s encrypt SSL certificate.Edit: if you’re having trouble with Docker-Compose, read this follow-up post.Step one: make sure you have ...
-
February 28, 2017
Can the exact same module code run on Drupal 7 and 8?
As the maintainer of Realistic Dummy Content, having procrastinated long and hard before releasing a Drupal 8 version, I decided to leave my (admittedly inelegant) logic intact and abstract away the Drupal 7 code, with the goal of plugging in Drup...
-
October 02, 2016
When not to use Drupal
Unless you work exclusively with Drupal developers, you might be hearing some criticism of the Drupal community, among them: We are almost cult-like in our devotion to Drupal; maintenance and hosting are expensive; Drupal is really complicated;...
-
September 30, 2016
Migrating data from Drupal to Jekyll
This technical post will run through how I went about migrating this site (the Dcycle blog) from Drupal to Jekyll. For the reasons why I migrated, please see Know when not to use Drupal.Exporting very simple content from Drupal to JekyllDepending ...
-
September 19, 2016
Using Docker to evaluate, patch or develop Drupal modules
Docker is now available natively on Mac OS in addition to Linux. Docker is also included with CoreOS which you can run on remote Virtual Machines, or locally through Vagrant.Once you have installed Docker and Git, locally or remotely, you don’t ne...
-
May 08, 2016
Using git bisect to determine when a failure was introduced
So your project’s tests are failing and you’re not sure when the failure was introduced. Your git history might look like:f09c875 - failing commit9344dc8 - ?a84feca - ?1a66df1 - ?05e4293 - ?acbddb6 - ?5fb7fac - ?fba9f93 - ?93cdfa0 - ?c9e0fc2 - ?80...
-
February 09, 2016
Compass Sass to CSS using Docker
Edit 2024-03-27: due to the issue upgrade the image to the OCI Format or Docker Image manifest v2, schema 2 #2, the technique presented in this post is no longer working; we recommend avoiding SASS and SCSS in favour of plain CSS. For more informa...
-
November 16, 2015
Gitsubmodulizing and Gitflow
Gitflow is a development workflow we use where all features are developed on their own branch, and we constantly merge in the mainline (in this example it will be master) to the feature branches, until the feature branches are ready, at which poin...
-
September 11, 2015
Debugging a hanging PHP script
I installed a script called test.php on a Vagrant box with CentOS 6.x and PHP 5.3. I made my script available at http://example.local/test.php and it contains:<?phpfunction whatever() { sleep(1);}while (TRUE) { whatever();}When I access this ...
-
July 27, 2015
Fixing "Docker error : no space left on device" by increasing the size of your CoreOS VM
You might get this error especially with very large projects. We are assuming that your setup is: Your local “bare metal” computer (can be any OS). CoreOS running on Vagrant and VirtualBox. Containers running via Docker on CoreOS.We are assumin...
-
July 16, 2015
Date-related tests failing on one environment and passing on another? Make sure your timezone is always the same
PHPUnit tests, or Drupal simpletests, are sometimes used to make sure your functions calculating date and times work correctly.I recently had a failure on my continuous integration server where a year was one day more than it was supposed to be. O...
-
July 07, 2015
What does it take to succeed with TDD, and why should you make the effort?
A few weeks ago, I participated in an online panel on the subject of Test-Driven Development as part of Continuous Discussions (#c9d9), a series of community panels about Agile, Continuous Delivery and DevOps. Watch a recording of the panel:Contin...
-
July 06, 2015
Catching watchdog errors in your Simpletests
If you are using a site deployment module, and running simpletests against it in your continuous integration server using drush test-run, you might come across Simpletest output like this in your Jenkins console output:Starting test MyModuleTestCa...
-
June 10, 2015
Add unit testing to legacy code
Edit, this blog post is deprecated, see blog.dcycle.com/unit instead!To me, modern code must be tracked by a continuous integration server, and must have automated tests. Anything else is legacy code, even if it was rolled out this morning.In the ...
-
February 23, 2015
Continuous integration with Circle CI and Docker for your Drupal project
Continuous integration (CI) is the practice of running a series of checks on every push of your code, to make sure it is always in a potentially deployable state; and to make sure you are alerted as soon as possible if it is not.Continuous integra...
-
February 18, 2015
A quick intro to Docker for a Drupal project
I recently added Docker support to Realistic Dummy Content, a project I maintain on Drupal.org. It is now possible (with Docker installed, preferably on a CoreOS VM) to run ./scripts/dev.sh directly from the project directory (use the latest dev v...
-
February 17, 2015
Rebasing in Git (squashing commits)
Here is a typical usecase: You master branch contains your code in a potentially deployable state You have a feature branch, with a bunch of commits. When your feature branch is ready, you want to merge it to master as a single commit.For examp...
-
February 09, 2015
Drupal and Docker: Creating a new Docker image based on an existing image
To get the most of this blog post, please read and understand Getting Started with Docker (Servers for Hackers, 2014/03/20). Also, all the steps outlined here have been done on a Vagrant CoreOS virtual machine (VM).I recently needed a really simpl...
-
February 06, 2015
Two tips for debugging Simpletest tests
I have been using Simpletest on Drupal 7 for several years, and, used well, it can greatly enhance the quality of your code. I like to practice test-driven development: writing a failing test first, then run it multiple times, each time tweaking t...
-
January 20, 2015
Multiple git remotes, the --depth parameter and repo size
When building a Drupal 7 site, one oft-used technique is to keep the entire Drupal root under git (for Drupal 8 sites, I favor having the Drupal root one level up).Starting a new project can be done by downloading an unversioned copy of D7, and in...
-
December 04, 2014
Using Gerrit to review a change to your code
Gerrit is a free open-source code review platform created by Google. In this post we will develop code locally and review it in Gerrit.Step 1: install Gerrit and set up your git repo. Start by installing a Gerrit server at http://gerrit.example.c...
-
December 04, 2014
Setting up Gerrit with a git repo
Gerrit is a free open-source code review platform created by Google. In this post we will set up Gerrit with a Git repo.Step 1: install GerritSee this post for instructions on how to install Gerrit on CentOS. We will assume that your Gerrit instan...
-
December 03, 2014
What is content? What is configuration?
What is content? What is configuration? At first glance, the question seems simple, almost quaint, the kind one finds oneself patiently answering for the benefit of Drupal novices: content is usually information like nodes and taxonomy terms, whil...
-
December 02, 2014
Setting up Phabricator to track a git repo
Phabricator is a free open-source code review and workflow management system. Here is how it can be used to track a git repo.Step 1: install PhabricatorIf you are just evaluating Phabricator you can use these instructions to set up an evaluation v...
-
December 02, 2014
Setting up Phabricator to review code
Phabricator is a free open-source code review and workflow management system. Here is how it can be integrated into a code-review workflow.Step 1: install Phabricator and make it track a git repo If you are just evaluating Phabricator you can use...
-
December 02, 2014
Setting up Gerrit on CentOS for evaluation
Gerrit is a free open-source code review platform created by Google. Here is how to set up a quick, insecure version of Gerrit for evaluation.You might also be interested in Phabricator (installing, linking with git, and reviewing code), another p...
-
December 02, 2014
Installing an evaluation version of Phabricator
Phabricator is a free open-source code review and workflow management system. Here is how to quickly install Phabricator in a manner which should be considered non-secure, so you can determine if it is right for you. You might also be interested i...
-
September 10, 2014
An approach to code-driven development in Drupal 8
What is code-driven development and why is it done?Code-driven development is the practice of placing all development in code. How can development not be in code?, you ask.In Drupal, what makes your site unique is often configuration which resides...
-
July 30, 2014
New Drupal 7 project checklist
I had this checklist documented internally, but I keep referring back to it so I’ll make it available here in case anyone else needs it. The idea here is to document a minimum (not an ideal) set of modules and tasks which I do for almost all proje...
-
May 23, 2014
Test your sad path first
One of the techniques I use to make sure I write tests is to write them before I do anything else, which is known as test-driven development. If you develop your functionality before writing a test, in most cases you will never write the test to g...
-
April 22, 2014
Simpletest Turbo: how I almost quadrupled the speed of my tests
My development team is using a site deployment module which, when enabled, deploys our entire website (with translations, views, content types, the default theme, etc.).We defined about 30 tests (and counting) which are linked to Agile user storie...
-
February 26, 2014
Eight tips to remember on your path to automated testing
Many Drupal projects now under maintenance suffer from technical debt: a lot of the functionality is in the database and outside of git, and the code lacks automated testing. Furthermore, the functionality is often brittle: a change to one feature...
-
February 11, 2014
Connecting Jenkins and Git
For your Jenkins job to connect to Git, you need two things: An ssh key on your jenkins account The Jenkins user needs to have a public private key pair. To do this you need to log into your command line as the jenkins user. Here is how. Use...
-
January 20, 2014
Do not use incremental IDs in your code
Drupal uses incremental IDs for such data as taxonomy terms and nodes, but not content types or vocabularies. If, like me, you believe your site’s codebase should work with different environments and different databases, your incremental IDs can b...
-
January 07, 2014
Do not clone the database
It is generally agreed that cloning the database downstream (that is, from development toward production) is a bad idea, if only because by doing so all production content is lost; most developers use Features, Context, some variation on a site de...
-
December 13, 2013
Continuous deployment, Drupal style
Edit (2016-10-03): This website is no longer Drupal-based.Deployments are often one of the most pain-inducing aspects of the Drupal development cycle. I have talked to Drupal developers in several shops, and have found that best practices are ofte...
-
November 22, 2013
What is a site deployment module?
In a Drupal development-staging-production workflow, the best practice is for new features and bug fixes to be developed locally, then moved downstream to the staging environment, and later to production.Just how changes are pushed downstream vari...
-
November 13, 2013
Case study: installing mock objects for testing Drupal-Nuxeo synchronisation
I recently inherited a Drupal project which periodically imported content from a Nuxeo server, synchronizing it with Drupal nodes, thus creating, updating and deleting nodes as need be. Nuxeo content was in no case modified by Drupal.The Nuxeo ser...
-
November 13, 2013
An approach to deploying translations for a multilingual site
Let’s say you are working locally and you need to add a new module to the site. Here is an example with Login Toboggan:Let’s start by downloading the module to our local dev sitedrush dl logintobogganInstead of enabling it outright, we’ll want to ...
-
November 11, 2013
Don't perform logic in your hook_form_submit: use an API
Examples like these are rampant throughout Drupal 7, in block_admin_display_form_submit(), for example:/** * Form submission handler for block_admin_display_form(). * * @see block_admin_display_form() */function block_admin_display_form_submit($fo...
-
October 29, 2013
Using Drush and SSH to clone a remote database
Sometime one needs to clone an entire remote website in order to diagnose certain problems. Here’s how I go about it:The following example assumes that: You have a local webserver, in this example MAMP. You have Drush installed both locally and ...