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' })
@jeanpaulrsoucy
jeanpaulrsoucy / git_export_all_file_versions.sh
Created November 24, 2021 21:34
Extract all versions of a file from the Git repository history.
#!/bin/sh
# based on script provided by Dmitry Shevkoplyas at http://stackoverflow.com/questions/12850030/git-getting-all-previous-version-of-a-specific-file-folder
set -e
if ! git rev-parse --show-toplevel >/dev/null 2>&1 ; then
echo "Error: you must run this from within a git working directory" >&2
exit 1
fi
@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 May 21, 2025 19:35
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.md
Last active August 29, 2025 11:20
Fix DNS resolution in WSL2

Permanent WSL DNS Fix (WSL 2.2.1+)

If you're encountering ping github.com failing inside WSL with a Temporary failure in name resolution, you're not alone — this has been a long-standing issue, especially when using VPNs or corporate networks.

This issue is now fixed robustly with DNS tunneling, which preserves dynamic DNS behavior and avoids limitations like WSL’s former hard cap of 3 DNS servers in /etc/resolv.conf.

DNS tunneling is enabled by default in WSL version 2.2.1 and later, meaning that if you're still seeing DNS resolution issues, the first and most effective fix is simply to upgrade WSL. Upgrading WSL updates the WSL platform itself, but does not affect your installed Linux distributions, apps, or files.

To upgrade WSL, follow these steps,