Skip to content

Instantly share code, notes, and snippets.

View megclaypool's full-sized avatar

Meg Claypool megclaypool

View GitHub Profile
@megclaypool
megclaypool / notes.md
Last active February 19, 2025 18:52
[How to change the name a Mac app displays in the menu bar] [Answer from AskDifferent](https://apple.stackexchange.com/a/385074/225185) I use this to rename "Firefox Developer Edition" to "FF Dev" so my menu bar doesn't overflow!

Renaming the .app package in Finder only changes the name there, it doesn't change the name shown in the menu. To do so edit YOUR.app/Contents/Resources/XY.lproj/InfoPlist.strings (with XY being the language you are using) and change CFBundleName there.

For applications without localization files you can also edit YOUR.app/Contents/Info.plist and set a new value for CFBundleName there.

Managing CSS and JavaScript files in Drupal 8 with Libraries

Thought byDavid Hernandez March 14, 2016 Drupal 8 CSS and JavaScript

Drupal 8 revolutionizes the theming experience with many significant improvements to make theming easier, and give themers the flexibility and control they've never had before. One of those major improvements is to the library management system, which controls the attaching of CSS and JavaScript files.

In this post we will cover how to create and control libraries from a theme. This will include SMACSS categorization for CSS files, dependencies, how to conditionally attach libraries, manipulating libraries that come from anywhere in a site (core, modules, or base themes,) and targeting individual files for removal or replacement. All this without needing a single line of PHP. Creating Libraries

In Drupal 9.4, jQuery.once() has been removed. However, there's a Javascript function, once(), that can replace it with a little rewriting:

var closeButton = $("#off-canvas .offcanvas__close");
      
closeButton.once().on("click", function () {
  closeOffCanvas();
});

once takes 3 arguments: 1. Arbitrary key, 2. CSS selector, 3. context

❗When you install qBittorrent, make sure to install NordVPN first. Then you want to make sure to limit qBittorrent so it will only use NordVPN’s connection (saving you from getting in trouble if you forget to turn on the VPN before torrenting).

  1. Make sure NordVPN is disconnected
  2. In Terminal, type ifconfig
  3. Connect NordVPN
  4. In Terminal, type ifconfig again
  5. Find the connection that’s been added (in my case, it was utun4)
  6. In qBittorrent, open the preferences and click on Advanced
  7. Set the Network Interface to your NordVPN connection and click OK.
  8. Test it by heading over to the Ubuntu alternative downloads page (these files are totally legal to download, so if something goes wrong you won’t get in trouble)
  9. Pick a few versions of Ubuntu to download, and load the (old fashioned non-magnet 😛 ) torrent files into qBittorrent

To list the fonts that are available on your system, run the following command in the terminal:

system_profiler -json SPFontsDataType | grep \"family | sort | uniq

This will show the name you need to supply to VSCode to use the font.

Any font that is activated on the Mac will be available to VSCode. I am using a patched font, and by applying the name that is shown using the command above, I was able to use it in VSCode.

@megclaypool
megclaypool / themename.theme
Last active November 9, 2023 20:20
[Load code into head of Drupal site] On NIJC the client wanted to load a hotjar script into the head of the document (which then calls another script and attaches it to the head). However, they only wanted the script to load on certain pages. Here's
/**
* implements hook_page_attachments_alter
* @param array $attachments
*/
//thanks: https://www.drupal.org/theme-guide/8/assets#configurable-javascript
function gavias_tico_subtheme_page_attachments_alter(array &$attachments) {
/**
* Hotjar tracking code for NIJC
*/

[Fix for Prettier Error: Unexpected doc.type 'concat']

As of 10-30-2023, the Prettier Melody plugin that allows Prettier to work on .twig files hasn't been updated in ages. Meanwhile, Prettier has been updated to 3.0, which (it turns out) was a breaking change as far as the Twig Melody plugin is concerned.

The Solution

Downgrade your Prettier to 2.8 using npm install [email protected]

@megclaypool
megclaypool / filter.php
Last active December 9, 2024 14:02
[Add a submenu toggle button to WordPress menu items with children] Here are the PHP code and JS that will let you create a toggle and cause it to actually toggle classes and aria-expanded attributes. Use styles to show and hide the submenu, and to
// Add this to an appropriate php file in your theme
// Change the function name and the "visually-hidden" class name as appropriate
// Note that this is a WireMedia theme, so is using their icons function.
// You can use css to create the chevron instead
require_once 'icons.php';
function j40a_parent_menu_item_buttons($output, $item, $depth, $args) {
if (in_array('menu-item-has-children', $item->classes, true)) {
@megclaypool
megclaypool / RenderMenu.php
Last active August 23, 2023 01:16
These are set up as Twig functions in a module in the NIJC site. This might be pretty sweet to import as a Radicati Drupal module?
<?php
/**
* @file
* Contains \Drupal\custom_blocks_forms\Twig\KintExtension.
*/
namespace Drupal\custom_blocks_forms\Twig;
use Drupal;