Skip to content

Instantly share code, notes, and snippets.

View vladdancer's full-sized avatar
🖖

Vlad Moyseenko vladdancer

🖖
View GitHub Profile
@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;"
@shramee
shramee / upwork-sum-pending.js
Last active July 23, 2018 15:45
Just paste this in console on page earnings history after logging in. https://www.upwork.com/earnings-history/
function getPending() {
var amount = 0;
$( 'tr.oPending' ).each( function() {
var
$t = $(this),
amt = $t.children( ':eq(4)' ).html().split( '<br>' )[0];
amt = amt.trim().replace( '$', '' )
if ( 0 == amt.indexOf( '(' ) ) {
amt = amt.replace( '(', '' ).replace( ')', '' ) * -1
}
@dinarcon
dinarcon / migrate_plus.migration.omdb_json.yml
Last active July 3, 2022 11:03
Drupal 8 JSON Migration Example
# This is the *third* configuration to import with configuration type: 'Migration'
# This migration demonstrates importing from a monolithic JSON file.
# Forked from https://github.com/heddn/json_example_migrate/blob/json/web/modules/custom/custom_migrate/config/install/migrate_plus.migration.omdb_json.yml
uuid: b113ad9f-1ed7-43e5-802c-0e0270d2b7fa
id: omdb_json_article
label: JSON feed of movies (Article)
migration_group: json_example
source:
# We use the JSON source plugin.
plugin: url
@rang501
rang501 / file.php
Last active August 28, 2024 06:59
Drupal 8 get image dimensions by applying image style effects. This doesn't cause performance issue because the dimensions are calculated without creating the actual image.
$image = \Drupal::service('image.factory')->get($file->getFileUri());
$image_style = \Drupal\image\Entity\ImageStyle::load('gallery_large');
// Set source image dimensions.
$dimensions = [
'width' => $image->getWidth(),
'height' => $image->getHeight(),
];
// After calling this, the $dimensions array will contain new dimensions.
$image_style->transformDimensions($dimensions, $file->getFileUri());
##
## How to install mcrypt in php7.2 / php7.3
## Linux / MacOS / OSX
##
## https://lukasmestan.com/install-mcrypt-extension-in-php7-2/
#
@andypost
andypost / Makefile
Last active December 17, 2023 18:43
drupal 10 core contributor docker kickstarter
.PHONY: up upx log down exec exec0 h t
CUID := $(shell id -u)
CGID := $(shell id -g)
IMAGEPHP := skilldlabs/php:8
all: | exec
up:
docker run --rm --name core9 \
ubuntu@claw:/var/www/html/drupal/web/modules/contrib/islandora$ drupal config:override
Enter configuration name [at_core.settings]:
> system.file
Enter the configuration key [allow_insecure_uploads]:
> temporary_maximum_age
Enter the configuration value:
> 1
Configuration name system.file
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active April 29, 2025 16:57
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@vasi
vasi / dry_run.php
Created March 30, 2017 19:12
Drupal migrate dry run
<?php
use Drupal\migrate_plus\Event\MigrateEvents as MigratePlusEvents;
use Drupal\migrate_plus\Event\MigratePrepareRowEvent;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
function dry_run_migration($migration_id) {
// Get the migration source.
$migrationManager = \Drupal::service('plugin.manager.config_entity_migration');
$migration = $migrationManager->createInstance($migration_id);
@FinBoWa
FinBoWa / xdebug-off.sh
Last active December 12, 2017 00:07
Xdebug on
#/bin/sh
CURRENT_USER=`whoami`
if [ "$CURRENT_USER" == "vagrant" ]; then
cd /vagrant; ./xdebug.sh off
else
vagrant ssh -c "cd /vagrant; sudo ./xdebug.sh off"
fi