Skip to content

Instantly share code, notes, and snippets.

View Erikdekamps's full-sized avatar

Erik de Kamps Erikdekamps

View GitHub Profile
@Erikdekamps
Erikdekamps / dummy.html
Last active August 1, 2023 09:41 — forked from mikker/dummy.html
<h1>Testing display of HTML elements</h1>
<p>This is the document <code>header</code></p>
<h1>This is 1st level heading</h1>
<p>This is a test paragraph.</p>
<h2>This is 2nd level heading</h2>
<p>This is a test paragraph.</p>
<h3>This is 3rd level heading</h3>
<p>This is a test paragraph.</p>
<h4>This is 4th level heading</h4>
<p>This is a test paragraph.</p>
@Erikdekamps
Erikdekamps / add_translations.install
Last active June 6, 2023 07:40
Drupal 8 - Programmatically translate strings via hook_update_N()
/**
* Helper function for adding translations.
*
* @param array $strings
* The array with strings and their translations.
*/
function _my_module_add_translations(array $strings) {
// Get locale storage service.
$storage = \Drupal::service('locale.storage');
@Erikdekamps
Erikdekamps / module.install
Last active May 27, 2021 12:56
Drupal 8 - Load taxonomy terms sorted by weight
/**
* Get taxonomy terms sorted by weight.
*
* @param int $vid
* The vocabulary id.
*
* @return array
* Returns an array of term id | name.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
@Erikdekamps
Erikdekamps / module.install
Last active January 10, 2019 08:24
Drupal 8 - Create taxonomy terms with translations programmatically
// The languages array.
$languages = [
'dutch' => [
'label' => 'Dutch',
'translations' => [
'nl' => 'Nederlands',
'de' => 'Niederländisch',
],
],
'english' => [
@Erikdekamps
Erikdekamps / mixed-content-scan
Last active March 21, 2018 09:11
mixed-content-scan
Get: https://github.com/bramus/mixed-content-scan
Fix: ~/.composer/vendor/bin directory in your PATH
Run: ~/.composer/vendor/bin/mixed-content-scan http://example.com --output=/Users/username/Desktop/results.txt
From: https://www.a2hosting.com/kb/developer-corner/mysql/determining-the-size-of-mysql-databases-and-tables
To determine the sizes of all of the tables in a specific database, at the
mysql> prompt, type the following command. Replace database_name with the
name of the database that you want to check:
SELECT table_name AS "Table",
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)"
FROM information_schema.TABLES
WHERE table_schema = "DATABASE_NAME"
@Erikdekamps
Erikdekamps / check_http_codes_from_file.sh
Last active March 20, 2017 11:36
cURL - Get http codes from list of urls
#!/bin/bash
while read LINE; do
# cURL the url and write to file.
curl -o /dev/null --silent --progress-bar --head --write-out '%{http_code} | %{url_effective}\n' "$LINE" >> result.txt
# Echo the line in terminal.
echo "$LINE"
# The file name below.
done < urls.txt