Skip to content

Instantly share code, notes, and snippets.

@pustynnykh
pustynnykh / gist:9bd6e93a27485860f2e6f6c5d247b96f
Created November 8, 2016 10:49
Unique users login count per day in specified period using login_history database table in Drupal 7
SELECT FROM_UNIXTIME(login, '%Y/%m/%d') AS dates, count(distinct(uid)) as theCount
FROM login_history
WHERE login BETWEEN 1478476800 AND 1478645999
GROUP BY dates
/**
* Implements Migration::prepare().
* This func fix empty fc's on migrate update operation.
* Used as fix while performs updates,
* drush mi AlNodeInstitution --idlist="8013" --force --update.
*/
public function prepare($entity, stdClass $row) {
// Don't run on initial import only on update.
if (isset($entity->nid)) {
// Load the original node object.
@pustynnykh
pustynnykh / template.php
Created September 2, 2014 12:22
Remove text format selection from node creating page
<?php
/**
* Remove text format selection from node creating page
* Implements of hook_element_info_alter().
*/
function YOURTHEME_element_info_alter(&$type) {
// Our process callback must run immediately after filter_process_format().
$filter_process_format_location = array_search('filter_process_format', $type['text_format']['#process']);
$replacement = array('filter_process_format', 'YOURTHEME_filter_process_format');
array_splice($type['text_format']['#process'], $filter_process_format_location, 1, $replacement);
@pustynnykh
pustynnykh / block system main view
Created August 27, 2014 11:13
Drupal new theme suggestion for block system main with view. Put it to template.php
function theme_preprocess_block(&$vars) {
$block = $vars['block'];
if($block->module == 'system' && $block->delta == 'main' && function_exists('views_get_page_view') && views_get_page_view()){
$view_object = views_get_page_view();
$vars['theme_hook_suggestions'][] = 'block__views__' . $view_object->name;
}
}
@pustynnykh
pustynnykh / hovereffectusing:after
Created June 19, 2014 10:15
Cool hover-effect using :after
<div class="wrapper">
<div class="circle"></div>
</div>
.wrapper {
background: #000;
width: 100px;
height: 100px;
position: relative;
}