Skip to content

Instantly share code, notes, and snippets.

View GueGuerreiro's full-sized avatar
🏠
Working from home

Miguel Guerreiro GueGuerreiro

🏠
Working from home
View GitHub Profile
@thejimbirch
thejimbirch / breadcrumb.html.twig
Created April 13, 2020 13:05
Add Schema.org BreadcrumbList inline in Drupal 8+ in your theme's templates.
{#
/**
* @file
* Theme override for a breadcrumb trail.
*
* Available variables:
* - breadcrumb: Breadcrumb trail items.
*/
#}
{% if breadcrumb %}
@pmeinhardt
pmeinhardt / hmm
Created June 24, 2019 08:37
Find out what you did today
#!/usr/bin/env bash
#
# Find out what you did today
#
# Lists all your commits from repos found in the given paths.
# Use it to prepare your daily stand-up or to write job logs.
#
# Uses `git`, depends on `fd` - install via `brew install fd`.
#
# Usage:
@jleehr
jleehr / gist:7ac2a5de785881dfce99f7034547f07b
Last active May 25, 2023 11:02
Drupal 8 - Migrate from public to private files
# Enable maintanance mode
drush state-set system.maintenance_mode 1
# Backup file field data
drush sql-query "CREATE TABLE media__field_file_bak AS SELECT * FROM media__field_file;"
drush sql-query "CREATE TABLE media_revision__field_file_bak AS SELECT * FROM media_revision__field_file;"
# Truncate file field tables (need to change storage settings)
drush sql-query "TRUNCATE media__field_file;"
drush sql-query "TRUNCATE media_revision__field_file;"
@crittermike
crittermike / get_node_by_path.php
Created September 16, 2016 15:15 — forked from thagler/get_node_by_path.php
Drupal 8 Get node ID by path alias
<?php
$path = \Drupal::service('path.alias_manager')->getPathByAlias('/this-is-the-alias');
if(preg_match('/node\/(\d+)/', $path, $matches)) {
$node = \Drupal\node\Entity\Node::load($matches[1]);
}
@pmeinhardt
pmeinhardt / download-site.md
Created October 10, 2013 17:12
download an entire page (including css, js, images) for offline-reading, archiving… using wget

If you ever need to download an entire website, perhaps for off-line viewing, wget can do the job — for example:

$ wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains website.org --no-parent  www.website.org/tutorials/html/

This command downloads the website www.website.org/tutorials/html/.

The options are:

  • --recursive: download the entire website
  • --domains website.org: don't follow links outside website.org