Skip to content

Instantly share code, notes, and snippets.

View vladdancer's full-sized avatar
🖖

Vlad Moyseenko vladdancer

🖖
View GitHub Profile
@skounis
skounis / dump-nocache.sh
Last active November 14, 2023 14:09
Dump Drupal DB without cache tables with drush
# Without cache
drush sql-dump --structure-tables-list=cache,cache_* > dumpfile.sql
# Without cache, search index and watchdog
drush sql-dump --structure-tables-list=cache,cache_*,search_index,watchdog > dumpfile.sql
# Without table spaces
drush sql-dump --structure-tables-list=cache,cache_*,search_index,watchdog --extra-dump="--no-tablespaces --column-statistics=0 --set-gtid-purged=OFF" > db.sql
@ebta
ebta / mysqldump and mysqlpump backup.md
Last active April 3, 2023 03:13
Backup MySQL database using mysqldump & mysqlpump

Backup Using mysqldump

Mysqldump is a command-line utility that is used to generate the logical backup of the MySQL database. It produces the SQL Statements that can be used to recreate the database objects and data. The command can also be used to generate the output in the XML, delimited text, or CSV format.

Note: By default, mysqldump command does not dump the information_schema database, performance_schema, and MySQL Cluster ndbinfo database. If you want to include the information_schema tables, you must explicitly specify the name of the database in the mysqldump command, also include the —skip-lock-tables option.

mysqldump -uroot -p  --all-databases > all-databases.sql
mysqldump -uroot -p dbname > dbname.sql
mysqldump -uroot -p dbname table1 table2 > dbname_table_1_2.sql
@davidjguru
davidjguru / intro_drupal_truncate_watchdog_table_using_drush.md
Last active April 22, 2024 11:27
Drupal 8 || 9 : Truncate Watchdog table using Drush from a DDEV deploy.
@rubenvarela
rubenvarela / custom_join.module
Created March 19, 2021 11:34
drupal 8, drupal 9 - Views - Add extra condition on join
<?php
/**
* @file
* Primary module hooks for custom_join module.
*/
use Drupal\views\Plugin\views\query\QueryPluginBase;
use Drupal\views\ViewExecutable;
@o5
o5 / dump.sh
Last active May 23, 2024 20:09
MySQL / MariaDB Dump Helper
#!/usr/bin/env bash
# MySQL / MariaDB Dump Helper
# ===========================
# FEATURES: Progress bar with ETA, support multiple databases (dump into separated files) and password as argument
# REQUIREMENTS:
# =============
# GNU Core Utilities, mysql, mysqldump, pv (https://github.com/icetee/pv)
@edutrul
edutrul / download-a-file-in-drupal9-drupal8.php
Last active December 2, 2022 12:48
How to download a file programmatically using guzzle in Drupal 8 / Drupal 9
<?php
$external_file = 'https://www.example.com/test.png'
$destination = 'sites/default/files/a-directory/test.png';
/** @var GuzzleHttp\Psr\Response $response */
$response = \Drupal::httpClient()->get($external_file, ['sink' => $destination]);
// file gets downloaded under /sites/default/files/a-directory/test.png
@robdecker
robdecker / 1.md
Last active November 26, 2021 08:35
[Fix Sequel Pro import error] #macos #sql

When I upload a database to Sequel Pro, I often get this 'file read error':

An error occurred when reading the file, as it could not be read in the encoding you selected (Autodetect - Unicode (UTF-8)).

Sequel Pro file read error

To solve this, delete all the tables and try again with encoding 'Western: Mac OS Roman'.

Sequel Pro encoding fix

@geowa4
geowa4 / confluence-to-pdf.js
Created January 3, 2019 03:12
Puppeteer to download Confluence PDF export
// PDF download hack taken from https://github.com/GoogleChrome/puppeteer/issues/610#issuecomment-340160025
const puppeteer = require("puppeteer");
const fs = require("fs");
(async () => {
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
await page.goto(
"https://synopsys.atlassian.net/wiki/spaces/INTDOCS/pages/622678/Running+Black+Duck+Detect+with+Bamboo"
);
@Rich-Harris
Rich-Harris / what-is-svelte.md
Last active March 27, 2024 06:09
The truth about Svelte

I've been deceiving you all. I had you believe that Svelte was a UI framework — unlike React and Vue etc, because it shifts work out of the client and into the compiler, but a framework nonetheless.

But that's not exactly accurate. In my defense, I didn't realise it myself until very recently. But with Svelte 3 around the corner, it's time to come clean about what Svelte really is.

Svelte is a language.

Specifically, Svelte is an attempt to answer a question that many people have asked, and a few have answered: what would it look like if we had a language for describing reactive user interfaces?

A few projects that have answered this question:

@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;"