Skip to content

Instantly share code, notes, and snippets.

@chupzzz
chupzzz / menuHover.vue
Created February 10, 2024 06:57
Quasar 2 menu on hover (Vue 3)
<template>
<q-button
label="Hover button"
@mouseenter="menuOver = true; checkMenu()" @mouseleave="menuOver = false; checkMenu()"
>
<q-menu
transition-show="jump-up" transition-hide="jump-down"
anchor="top middle" self="bottom middle"
:offset="[0, 2]"
no-parent-event v-model="menuStatus"
@chupzzz
chupzzz / variables.styl
Created August 30, 2017 07:20 — forked from shengt/variables.styl
Media queries variables for stylus
// Media queries breakpoints
// --------------------------------------------------
// Extra small screen / phone
$screen-xs ?= 480px
$screen-phone ?= $screen-xs
// Small screen / tablet
$screen-sm ?= 768px
$screen-tablet ?= $screen-sm
@chupzzz
chupzzz / taxonomy_find_term_by_parent.php
Created August 6, 2017 12:19
Find taxonomy term child (by name) limited by parent term (Drupal 7).
<?php
/**
* Find taxonomy term (by name) limited by parent term.
*
* In many cases you may need to find children in exact term (parent).
* Here we do this in efficent way with precise query (not like taxonomy_get_tree()
* where all the terms loading.
*
* @param $name
* @param $parent
@chupzzz
chupzzz / taxonomy_node_count.php
Last active July 7, 2017 18:26
Drupal 7: Get Taxonomy node count
<?php
/**
* @param tid
* Term ID
* @param child_count
* TRUE - Also count all nodes in child terms (if they exists) - Default
* FALSE - Count only nodes related to Term ID
* @param node_type
* Count only nodes of one type (string).
*/
@chupzzz
chupzzz / match_path.php
Created June 23, 2017 19:34
Match (check) given path for pattern/mask (like in Drupal blocks system).
<?php
$path = current_path();
$path_alias = drupal_lookup_path('alias', $path);
$patterns = '' . PHP_EOL . 'node/n' . PHP_EOL . 'blog/*';
if (drupal_match_path($path, $patterns) || drupal_match_path($path_alias, $patterns)) {
// Do things.
}
@chupzzz
chupzzz / array2csv.php
Created April 26, 2017 12:54
Convert array to CSV and return it
function array2csv($array) {
$csv = fopen('php://temp/maxmemory:'. (5*1024*1024), 'r+');
fputcsv($csv, $array, ';');
rewind($csv);
return stream_get_contents($csv);
}