Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / 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;?>>
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 / lastfm_delete_loved.js
Created May 7, 2017 06:38
Bulk delete Last.FM scrobbles & loved tracks
// On the Last.FM website go to the page which lists the tracks that you have loved.
// Open Chrome DevTools (or Firefox or any modern browser that has a built in Javacript Console)
// and run the following command.
// This basically clicks on all the delete buttons on the page and reloads the page.
jQuery('.love-button--loved').each(function(_, b) {
b.click();
});
location.reload();
@teknikqa
teknikqa / convert.md
Last active May 3, 2018 07:25
Convert AVI videos to WEBM & MP4 videos for use in webpage backgrounds.

MP4

Pass 1

ffmpeg -i input.avi -codec:v libx264 -profile:v high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:720 -threads 0 -pass 1 -an -f mp4 /dev/null

Pass 2

ffmpeg -i input.avi -codec:v libx264 -profile:v high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:720 -threads 0 -pass 2 -an -f mp4 output.mp4