Skip to content

Instantly share code, notes, and snippets.

View aramboyajyan's full-sized avatar

Aram Boyajyan aramboyajyan

View GitHub Profile
@aramboyajyan
aramboyajyan / .htaccess
Created August 3, 2016 11:10
Drupal force HTTPS in .htaccess
#
# Force SSL on the whole website.
#
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@aramboyajyan
aramboyajyan / snippet.php
Created July 20, 2016 07:47
Drupal 7 delete all terms from a vocabulary programmatically
$results = db_query("SELECT tid FROM {taxonomy_term_data} WHERE vid = :vid", array(':vid' => PLACE_HERE_VOCABULARY_ID))->fetchAll();
foreach ($results as $result) {
taxonomy_term_delete($result->tid);
}
@aramboyajyan
aramboyajyan / snippet.css
Last active July 4, 2016 19:57
Add a class to all images that are aligned left or right
img.float-left {
float: left!important;
margin: 6px 12px 10px 0!important;
}
img.float-right {
float: right!important;
margin: 6px 0 12px 10px!important;
}
@aramboyajyan
aramboyajyan / snippet.php
Last active May 30, 2016 10:53
Drupal 7 fix menu router
db_delete('menu_links')
->condition('module', 'system')
->execute();
menu_rebuild();
drupal_set_message(t('The menu router has been rebuilt.'));
@aramboyajyan
aramboyajyan / snippet.php
Created April 20, 2016 16:39
Drupal 7 watchdog for random messages
watchdog('debug', '@data', array('@data' => ''));
@aramboyajyan
aramboyajyan / snippet.sql
Created April 19, 2016 09:20
SQL for getting the list of active users without any role - Drupal 7
SELECT
u.uid,
u.name
FROM users u
LEFT JOIN users_roles r ON u.uid = r.uid
WHERE
u.uid > 0 AND
u.status = 1 AND
r.rid IS NULL
@aramboyajyan
aramboyajyan / profiles.make
Created March 28, 2016 06:37
Drush make with all 3 profiles
core = 7.x
api = 2
projects[] = drupal
projects[level1][type] = profile
projects[level1][download][type] = git
projects[level1][download][url] = https://github.com/aramboyajyan/d7level1
projects[level2][type] = profile
projects[level2][download][type] = git
@aramboyajyan
aramboyajyan / snippet.php
Created March 8, 2016 12:01
Drupal 7 clear variable cache
cache_clear_all('variables', 'cache_bootstrap');
@aramboyajyan
aramboyajyan / your_module.module
Created March 2, 2016 10:53
Prevent duplicate comment submissions in Drupal 7
<?php
/**
* Constants.
*/
// Number of minutes for which we will check if the user posted a duplicate comment.
define('YOUR_MODULE_OR_THEME_DUPLICATE_WINDOW', 5);
/**
* Implements hook_form_alter().
@aramboyajyan
aramboyajyan / script.sh
Created February 28, 2016 21:57
SSL: create CA certificate for bundles purchased from Comodo
cat COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt AddTrustExternalCARoot.crt > ca-bundle.crt