Skip to content

Instantly share code, notes, and snippets.

View Strae's full-sized avatar
🎯
Focusing

Daniele P. Strae

🎯
Focusing
View GitHub Profile
@Strae
Strae / commerce_bestsellers.sql
Created April 14, 2018 05:32 — forked from iAugur/commerce_bestsellers.sql
Drupal Commerce - Top selling Products
/**
* Get a list of the top selling products on a Drupal Commerce site
* If you have different product types - add them to the in list.
* Based on https://drupal.org/node/1292104#comment-6866420 by tmsimont https://drupal.org/user/566678
*/
SELECT node.title AS product_title, node.nid AS product_nid, COUNT(cp.title) AS order_count
FROM commerce_order
LEFT JOIN field_data_commerce_line_items as fdcli ON commerce_order.order_id = fdcli.entity_id AND (fdcli.entity_type = 'commerce_order' AND fdcli.deleted = '0')
INNER JOIN commerce_line_item as cli ON fdcli.commerce_line_items_line_item_id = cli.line_item_id
@Strae
Strae / check_if_entity_is_in_the_viewport.js
Created November 15, 2017 11:20
Aframe entity in viewport / visible
//RETURNS TRUE/FALSE BASED ON WHETHER OR NOT THE ENTITY IS VISIBLE
checkIfVisible(entity, camera){
let entityMesh = entity.object3DMap.mesh;
let frustum = new THREE.Frustum();
let cameraViewProjectionMatrix = new THREE.Matrix4();
camera.updateMatrixWorld();
camera.matrixWorldInverse.getInverse(camera.matrixWorld);
cameraViewProjectionMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
@Strae
Strae / _text.js
Created September 21, 2017 10:52
Aframe zoom control test
AFRAME.registerComponent( 'cth-zoom', {
schema: {
to: { type: 'string' }
},
init: function () {
var data = this.data;
var el = this.el;
var cameraEl = document.getElementById( 'cth-camera' );
el.addEventListener( 'click', function () {
var _camera = cameraEl.getAttribute( 'camera' );
@Strae
Strae / aframe-obj-opacity.md
Last active April 22, 2020 09:23
Aframe opacity on 3D objects

@source: https://stackoverflow.com/questions/43914818/alpha-animation-in-aframe-for-a-object-model

The built-in material component primarily works with primitives, so material="opacity: 0.5" and similarly opacity="0.5" will not work here. You'll need to modify the THREE.js materials created by your model, using a custom component. Example:

AFRAME.registerComponent('model-opacity', {
  schema: {default: 1.0},
  init: function () {
    this.el.addEventListener('model-loaded', this.update.bind(this));
  },
@Strae
Strae / module.module
Created June 22, 2017 08:04
Drupal 7 embed view with filters
$view = views_get_view('glossario');
$view->dom_id = hash( 'md5', microtime( true ) . mt_rand() );
$view->set_display('search_results');
$view->is_cacheable = FALSE;
$view->exposed_input['title'] = $_GET['term'];
return $view->render();
@Strae
Strae / .local__share__applications__menulibre-terminal.desktop
Last active July 19, 2017 13:16
Random terminator proifile (max 12)
[Desktop Entry]
Version=1.0
Type=Application
Name=Terminal
Icon=Terminal
Exec=PATH_OF_FILE_t.sh
NoDisplay=false
Categories=System;
StartupNotify=false
Terminal=false
@Strae
Strae / conky.conf
Created June 8, 2017 08:57
Conky simple vertical bars
alignment top_left
background no
border_width 0
default_color white
default_outline_color white
double_buffer yes
draw_borders no
draw_outline no
draw_shades yes
use_xft yes
@Strae
Strae / .bash_aliases
Last active September 28, 2017 15:14
Bash aliases tools
# best-alias-EVER
alias Grep="grep"
# show file/folders permissions on octal (e.g. 777) mode.
alias lso="ls -ahlG | awk '{k=0;for(i=0;i<=8;i++)k+=((substr(\$1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(\" %0o \",k);print}'"
# just shorthand.
alias nhost="sudo nano /etc/hosts"
# notify that something just happended.
# usefull for commands that require long time - e.g. mysqldump -u XXXXXXX && alert
alias alert="notify-send 'SOMETHING HAPPENED!' -u critical -i /home/dp/.icons/Numix-Circle/scalable/apps/popcorntime.svg"
# keep a debian machine updated. tbh, dunno if really usefull.
@Strae
Strae / Paginator.vue
Created May 29, 2017 08:18
Dead simple Vuejs paginator component
<template>
<nav v-if="0 < numResults" class="float pagination" aria-label="Page navigation">
<ul class="pagination">
<li v-if="show_prev">
<a href="#" class="no-underline" aria-label="First" v-on:click="first()">
<span aria-hidden="true">[1]</span>
</a>
</li>
<li v-if="show_prev">
<a href="#" class="no-underline" aria-label="Previous" v-on:click="prev()">
@Strae
Strae / terminator-random-profile.sh
Created May 5, 2017 09:59
Terminator random profile
#!/bin/bash
# Profiles must be named profile1, profile2, etc..
N=$(( ( RANDOM % 12 ) + 1 ));
terminator -p profile$N -T $N &