Skip to content

Instantly share code, notes, and snippets.

@brunodbo
brunodbo / app_back_button.js
Created March 26, 2024 23:48
This code adds a back button to the site header when our site is viewed in the MobiLoud app. When testing locally, everything works fine, but in the app, the `window.history.back()` method doesn't seem to work. I tested whether the event listener is being added in the app, and it is.
(function (Drupal, FontAwesome) {
'use strict';
Drupal.behaviors.appBackButton = {
attach: function (context) {
const mobileNavIconWrapper = document.getElementById('nav-mobile-show');
const isApp = navigator.userAgent.toLowerCase().includes('canvas');
if (!isApp) {
@brunodbo
brunodbo / import.php
Created April 29, 2019 21:14 — forked from crittermike/import.php
Importing Drupal 8 config programmatically
<?php
// Import arbitrary config from a variable.
$config = \Drupal::service('config.factory')->getEditable('filter.format.basic_html');
$config->setData($data)->save();
// Or, re-import the default config for a module or profile, etc.
\Drupal::service('config.installer')->installDefaultConfig('module', 'my_custom_module');
// Or, import YAML config an arbitrary directory.
@brunodbo
brunodbo / mymodule.libraries.yml
Created May 12, 2017 19:41 — forked from steffenr/mymodule.libraries.yml
Attach a CSS or JS library to a View in Drupal 8
custom_view:
css:
component:
css/custom_view.css: {}
@brunodbo
brunodbo / composer.json
Created April 10, 2017 16:51 — forked from joelpittet/composer.json
D8 Composer & Patches
{
"name": "drupal-composer/drupal-project",
"description": "Project template for Drupal 8 projects with composer",
"type": "project",
"license": "GPL-2.0+",
"authors": [
{
"name": "",
"role": ""
}
@brunodbo
brunodbo / firefox-developer-edition.desktop
Last active September 13, 2015 04:23 — forked from jaywink/firefox-developer-edition.desktop
Firefox Developer Edition (or any edition), separate Unity launcher icon (Ubuntu 14.04)
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=Firefox Developer Edition
Icon=/opt/firefox/browser/icons/mozicon128.png
Path=/opt/firefox/firefox
Exec=/opt/firefox/firefox --class="firefox-developer" -P dev-edition-default %u
StartupNotify=true
StartupWMClass=firefox-developer
#!/bin/bash
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
#
# Version 3, enhanced for Ubuntu 13.X+, Fedora 19+, and similar distros.
@brunodbo
brunodbo / Ubuntu audio
Last active January 11, 2016 00:23
Collection of links related to making music on a Ubuntu system
Setup
-----
- How to install Timidity++: https://help.ubuntu.com/community/Midi/SoftwareSynthesisHowTo
- Fix issues to get Ardour running (add user to audio group): http://manual.ardour.org/setting-up-your-system/platform-specifics/ubuntu-linux/
- Fix issues to get Ardour running (mv /etc/security/audio.conf.disabled to /etc/security/audio.conf): https://community.ardour.org/node/7237
- Setup MIDI in Jack: http://manual.ardour.org/setting-up-your-system/setting-up-midi/midi-on-linux/
Ardour plugins
--------------
@brunodbo
brunodbo / git-php-webhook.php
Created August 20, 2014 21:47
A basic webhook for deploying updates to repos on Github to your local server
<?php
/**
* This script is for easily deploying updates to Github repos to your local server. It will automatically git clone or
* git pull in your repo directory every time an update is pushed to your $BRANCH (configured below).
*
* INSTRUCTIONS:
* 1. Edit the variables below
* 2. Upload this script to your server somewhere it can be publicly accessed
* 3. Make sure the apache user owns this script (e.g., sudo chown www-data:www-data webhook.php)
* 4. (optional) If the repo already exists on the server, make sure the same apache user from step 3 also owns that
@brunodbo
brunodbo / gist:7622091
Created November 24, 2013 01:07
Leaflet onEachFeature() function to show polygon coordinates in a popup. Useful for cleaning a up geodata file.
function onEachFeature(feature, layer) {
var coordinates = feature.geometry.coordinates[0];
var coordinatesString = '';
$.each(coordinates, function(key, value) {
coordinatesString = coordinatesString + '[' + value + ']';
});
var popup = L.popup().setContent(coordinatesString);
layer.bindPopup(popup);
}