Skip to content

Instantly share code, notes, and snippets.

@robertsLando
robertsLando / README.md
Last active September 27, 2021 09:09
Temperature/ON-OFF Week Scheduler UI-Template Node-Red Dashboard

This allows users to set up a 24h scheduler for each day of the week in a quick and easy way.

It is a customization of Peter Scargill Thermostat Weekend so all credits goes to him.

In the Comment node you can find instructions on how to create more schedulers in the same UI, just need to copy/paste the flow of a single scheduler and find/replace the name of variables listed in the Comment node.

UI Preview

alt text

@thiamsantos
thiamsantos / links.js
Created February 21, 2017 00:14
Social Media Sharing URLS
@erd0s
erd0s / rowspan.js
Last active February 24, 2023 16:04
Turn an HTML table with rowspans into a csv with rowspan data duplicated
var rows = document.querySelectorAll("table div table > tbody tr");
var records = [];
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
var cells = row.querySelectorAll("td");
cells.forEach((o, j) => {
// Put in the forward rows data
if (o.rowSpan > 1) {
@sgomes
sgomes / functions.scss
Last active September 27, 2022 12:36
[Using Sass to automatically pick text colors] #4 - step 2
/**
* Calculate the luminance for a color.
* See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
*/
@function luminance($color) {
$red: nth($linear-channel-values, red($color) + 1);
$green: nth($linear-channel-values, green($color) + 1);
$blue: nth($linear-channel-values, blue($color) + 1);
@return .2126 * $red + .7152 * $green + .0722 * $blue;
@Bhavdip
Bhavdip / sketch-never-ending.md
Created October 6, 2016 15:53
Modify Sketch to never ending trial

###Sketch trial non stop

Open hosts files:

$ open /private/etc/hosts

Edit the file adding:

127.0.0.1 backend.bohemiancoding.com

127.0.0.1 bohemiancoding.sketch.analytics.s3-website-us-east-1.amazonaws.com

@annikaC
annikaC / AccountEditRedirectController.php
Created September 29, 2016 14:03
Drupal 8 redirect user to own user edit page (for use in menu links)
<?php
namespace Drupal\yourmodule\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* A controller that redirects to the current user's edit account page.
@Laro88
Laro88 / README.md
Created September 27, 2016 08:37
function to format data for chart to plot series of timestamp,value

The topic of interest in the "function slice and aggregate...." It solves the problem of plotting {timestamp, value} points, not just adding a new value.

It originates from polling a public api that exposes recorded IoT data. The data received contains the latest value for the inquired sensors, however since the data is timestamped, these should be respected in the plotting.

Notice: The context stores the obtained dataset and adds points if the timestamp is not previously seen. Some memory is wasted maintaining a lookup array that is not used for anything.

<?php
$referenced_files = $node->get('your_field')->referencedEntities();
$vars['download_article'] = file_create_url($referenced_files[0]->uri->value);
@raphaellarrinaga
raphaellarrinaga / drupal_8_twig_cheatsheet.md
Last active July 20, 2023 21:21
[Drupal 8 Twig cheatsheet] #tags: drupal8, twig, cheatsheet

Drupal 8 Twig cheatsheet

Please note I created that sheet as a personal side note/draft and not everything is fully tested. There could be errors or better things to do. So if you spot something wrong or something that can be improved, feel free to comment below and I will do the changes.

Getting Drupal 8 field values in Twig

Image path: {{ file_url(content.field_name['#items'].entity.uri.value) }}

@mortendk
mortendk / image-widget.html.twig
Created July 13, 2016 10:57
image widget upload label as a button trick
{#
.theme:
function birch_preprocess_image_widget(&$variables, $hook) {
// the image widget needs to know what the label is
// look in admin/image-widget.hmtl.twig
$variables['form_label_id'] = $variables['element']['#id'];
}
#}
{#