Skip to content

Instantly share code, notes, and snippets.

View yorkshire-pudding's full-sized avatar

Martin Price yorkshire-pudding

View GitHub Profile
@herbdool
herbdool / convert-d7media2backdrop.php
Last active November 18, 2023 02:26
Convert D7 Media to Backdrop Media
<?php
/**
* Convert d7 media to Backdrop media
*
* bee php-script convert-d7media2backdrop.php
*
* @todo add batching.
*/
@rockschtar
rockschtar / windows-wsl2-docker-lando-php-xdebug.md
Last active June 4, 2024 16:38
Windows 10/11 + WSL2 + Docker + Lando + PHP XDebug (PHPStorm, IntelliJ & Visual Studio Code (vscode))
  1. Install WSL
  2. Install your preferred WSL Linux Distro vom Microsoft Store. In my case I used Ubuntu 20.04.
  3. Install Docker for Windows
  4. Enable Docker WSL2 Integration image
  5. Install Lando inside WSL
wget https://github.com/lando/lando/releases/download/v3.6.0/lando-x64-v3.6.0.deb
dpkg -i --ignore-depends=docker-ce lando-x64-v3.6.0.deb
@john-doherty
john-doherty / add-query-params-to-url.js
Last active February 18, 2025 09:23
Add query string parameters to a URL in JavaScript (works with browser/node, merges duplicates and works with absolute and relative URLs)
/**
* Adds query params to existing URLs (inc merging duplicates)
* @param {string} url - src URL to modify
* @param {object} params - key/value object of params to add
* @example
* // returns /guides?tag=api
* addQueryParamsToUrl('/guides?tag=hardware', { tag:'api' })
* @example
* // returns https://orcascan.com/guides?tag=api
* addQueryParamsToUrl('https://orcascan.com/guides?tag=hardware', { tag: 'api' })
@klonos
klonos / bclone.sh
Created November 24, 2021 16:00
Clone a Backdrop project; optionally fetching one or more PRs locally.
#!/usr/bin/env bash
##
# Clone a Backdrop project; optionally fetching one or more PRs locally.
#
PROJECT=$1
PRS="${@:2}" # Get all arguments after the 1st one.
PROJECT_TYPES=("module" "theme" "layout" "profile")
PROJECT_TYPE=`wget --quiet --output-document=- https://raw.githubusercontent.com/backdrop-contrib/${PROJECT}/HEAD/${PROJECT}.info | awk '/type/ {print $3}'`
@klonos
klonos / startdrop.sh
Created November 24, 2021 15:43
Create a Backdrop instance using Lando.
ISSUE=$1
PR=$2
PHP=$3
INSTALL=$4
if [[ $(basename $PWD) = "docroot" ]]; then
echo "You are already in a docroot!!! Moving up one level..."
cd ..
fi
@TwoFistedJustice
TwoFistedJustice / bubbleUp.js
Last active June 22, 2024 19:23
This gist demonstrates how errors bubble up (or not) through the call stack depending on where you place your try-catch blocks.
/* This gist demonstrates how errors bubble up (or not) through the call stack
* depending on where you place your try-catch blocks
*
* You will get different results by reverse-commenting the two versions of the
* 'result' variable in topLevel()
* */
const topLevel = function(bool=false){
let name = topLevel.name;
try {
<?php
/**
* The table Printer class has no dependencies and generates an array of strings
* out of an array of objects or arrays and the child properties that should be printed given by an array of strings
*
* Should result in something like the following:
* +------+---------------+----------------+---------------+
* | id | name | col_name_three | col_name_four |
* +------+---------------+----------------+---------------+
@veuncent
veuncent / youtube_analytics_oauth.md
Last active August 3, 2024 02:58
Authentication for Google / YouTube Analytics using a Brand Account

Google / YouTube Authentication using a Brand Account

Below describes the only way I was able to get (programmatic) access to the YouTube Analytics API on behalf of our Brand Account. Google documentation is convoluted, to say the least, so if you know a more straightforward way, please do share.

Getting a Client ID and Refresh Token

  1. Create a Project in the Developers Console - https://console.developers.google.com/
  2. Go to the Library tab and enable desired APIs (e.g. YouTube Analytics)
  3. Go to OAuth consent screen and make project external. Select Test mode
@coltenkrauter
coltenkrauter / fix-wsl2-dns-resolution
Last active April 20, 2025 23:06
Fix DNS resolution in WSL2
More recent resolution:
1. cd ~/../../etc (go to etc folder in WSL).
2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line).
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line).
4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
5. cd ~/../../etc (go to etc folder in WSL).
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and
secondary.
@klonos
klonos / .lando.yml
Last active June 5, 2023 17:45
Backdrop Lando config
name: ???
# Use existing Backdrop recipe, then customize below.
recipe: backdrop
config:
# Where Backdrop resides, relative to this file.
webroot: docroot
database: mariadb
php: '?.?'
drush: '?.?.?'