Skip to content

Instantly share code, notes, and snippets.

Source: https://www.bluespark.com/blog/uninstalling-and-purging-field-modules-all-once
The job is divided in three parts: The data definition, field data purge and module list clean.
In the data definition task we provide all the required data we need to perform the task, the name of the field to delete, and given that
information, we get the field_info array and the name of the module to be uninstalled. Finally, field_delete_field() is executed.
After that the field data is purged in the batch body, and since we don't know how much data we will have to purge, we remove just 100
database rows per batch execution. After each purge we check if all the data has been removed to decide if we have to remove more data
from the database or continue to the final part.
@teknikqa
teknikqa / html.tpl.php
Created October 18, 2017 11:46 — forked from pascalduez/html.tpl.php
Drupal 7 — Move $scripts at page bottom
<!DOCTYPE html>
<html<?php print $html_attributes; ?>>
<head>
<?php print $head; ?>
<title><?php print $head_title; ?></title>
<?php print $styles; ?>
<?php print $head_scripts; ?>
</head>
<body<?php print $body_attributes;?>>
@teknikqa
teknikqa / drupalvm-setup.sh
Created January 7, 2018 13:35 — forked from kyletaylored/drupalvm-setup.sh
A shell script to help set up a standard DrupalVM project
#!/bin/bash
# Get project directory and git url
echo "Project code (used for project directory name):"
read project_code
echo "Project repo git url (can be blank):"
read project_git_url
# Clone DrupalVM
git clone git@github.com:geerlingguy/drupal-vm.git $project_code
@teknikqa
teknikqa / wp-get-admin.sql
Created February 5, 2018 05:49
Create Admin Account in WordPress through MySQL
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('newadminname', MD5('somerandomstrongpassword'), 'firstname lastname', 'email@domain.com', '0');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');
@teknikqa
teknikqa / createZip.php
Created April 9, 2018 11:39
Compress files into a single zip file
<?php
/**
* @file
* Creates a compressed zip file.
*
* @author Original Author: David Walsh
* @author Modified by: Nick Mathew
* @link https://davidwalsh.name/create-zip-php
*/
@teknikqa
teknikqa / fileDownload.php
Created April 9, 2018 11:40
Download helper to download files in chunks and save it
<?php
/**
* @file
* Download helper to download files in chunks and save it.
*
* @author Syed I.R
* @author Modified by: Nick Mathew
* @link https://github.com/irazasyed
*/
@teknikqa
teknikqa / drushrc.php
Created April 11, 2018 09:08
Open drush links in a specific browser
<?php
/**
* @file
* drushrc.php
*/
/**
* Open link in specific browser.
*
@teknikqa
teknikqa / fix-files-directories-permission-php.php
Created September 4, 2018 06:49 — forked from yuseferi/fix-files-directories-permission-php.php
Fix Files Directories Permissions by PHP code
<?php
fix_file_directory_permission(dirname(__FILE__));
function fix_file_directory_permission($dir, $nomask = array('.', '..')) {
if (is_dir($dir)) {
// Try to fix directories permission
if (@chmod($dir, 0755)) {
echo "<p>Permission Fixed for : " . $dir . "</p>";
}
}
@teknikqa
teknikqa / easywifi.txt
Last active January 23, 2019 10:13
Easy WiFi password sharing
Create a QR code with any QR generator in this format:
WIFI:S:<ssid>;T:<wpa|wep|>;P:<password>;;
Scanning this code will automatically add the WiFi details to the device. [1][2]
iOS will share the username and password. To prevent that, create a configuration file using
the iPhone configuration utility and have the QR code link to that file. This file can be on
Dropbox or any other server. [3]
@teknikqa
teknikqa / git add certain file types
Created May 9, 2019 07:11 — forked from stoplion/git add certain file types
git add all of certain file type
find . -name "*.sass" | xargs git add