Skip to content

Instantly share code, notes, and snippets.

View v1talii-dev's full-sized avatar

Vitalii Demchuk v1talii-dev

View GitHub Profile
@g0tmi1k
g0tmi1k / drupalgeddon2_CVE-2018-7600_SA-CORE-2018-002.md
Last active February 16, 2023 12:37
drupalgeddon2 / SA-CORE-2018-002 / CVE-2018-7600 cURL (PoC)
@parmentf
parmentf / GitCommitEmoji.md
Last active June 26, 2024 21:25
Git Commit message Emoji
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@Jaesin
Jaesin / delete_content_entities.d8.php
Created June 22, 2015 07:14
Delete all content entities in Drupal 8.
<?php
// Delete all nodes.
entity_delete_multiple('node', \Drupal::entityQuery('node')->execute());
// Delete all files.
entity_delete_multiple('file', \Drupal::entityQuery('file')->execute());
// Delete all taxonomy terms.
entity_delete_multiple('taxonomy_term', \Drupal::entityQuery('taxonomy_term')->execute());
@facine
facine / __INDEX.txt
Last active August 6, 2023 15:33
Drupal 8 - Examples
# Taxonomy terms:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_taxonomy_term-php
# Menu links:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_menu_link-php
# File items:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_file-php
# Nodes:
@star-szr
star-szr / mytheme.theme.php
Created March 28, 2014 19:33
Adding template suggestions for view modes and content types in Drupal 8
<?php
/**
* Implements hook_theme_suggestions_HOOK_alter() for node.html.twig.
*/
function MYTHEME_theme_suggestions_node_alter(array &$suggestions, array $variables) {
// Add template suggestions based on the current view mode.
$node = $variables['elements']['#node'];
$suggestions[] = 'node__' . $variables['elements']['#view_mode'];
$suggestions[] = 'node__' . $node->bundle() . '__' . $variables['elements']['#view_mode'];
}
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active June 22, 2024 05:19
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@hannesl
hannesl / gist:3864416
Created October 10, 2012 09:43
Delete/cancel a Drupal user programmatically and safely.
// Tell Drupal to cancel this user.
// The third argument can be one of the following:
// - user_cancel_block: disable user, leave content
// - user_cancel_block_unpublish: disable user, unpublish content
// - user_cancel_reassign: delete user, reassign content to uid=0
// - user_cancel_delete: delete user, delete content
user_cancel(array(), $uid, 'user_cancel_reassign');
// user_cancel() initiates a batch process. Run it manually.
$batch =& batch_get();
@lsolesen
lsolesen / my_module.info
Created April 1, 2011 08:56
Example on custom datetime filter for Views 3 for Drupal - see http://larsolesen.dk/node/273
core = "7.x"
name = "My Module"
description = "Example on how to add a filter handler with DATETIME"
package = "My modules"
php = "5.2.4"
project = "my_module"
version = "7.x-0.1"
files[] = "my_module_handler_filter_datetime.inc"