/*
Reading a serial ASCII-encoded string.
This sketch demonstrates the Serial parseInt() function.
It looks for an ASCII string of comma-separated values.
It parses them into ints, and uses those to fade an RGB LED.
Circuit: Common-Cathode RGB LED wired like so:
- red anode: digital pin 3 through 220 ohm resistor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# SOURCE VARIABLES | |
export token=xxxxx#admin token | |
export grafanaurl=http://xxx.xxx.xxx.xxx:3000/api | |
rm -rf backups | |
mkdir -p backups | |
cd backups |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"meta": { | |
"type": "db", | |
"canSave": true, | |
"canEdit": true, | |
"canAdmin": true, | |
"canStar": true, | |
"canDelete": true, | |
"slug": "labview-from-csv", | |
"url": "/d/qxQ3Wb67k/labview-from-csv", |
/*
Blink
Turns an LED on for one second, then off for one second, repeatedly.
Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
the correct LED pin independent of which board is used.
If you want to know what pin the on-board LED is connected to on your Arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_fans(ranked_machines, total_initial_consumption, total_current_consumption, n_fans): | |
# Resolve the recursion, because we have reached the target: "just below half of initial consumption" | |
if total_current_consumption <= total_initial_consumption / 2: | |
return n_fans | |
# Compute the site that have the largest amount of consumption and the | |
# total amount of consumption for the company | |
worse_machine = ranked_machines[0] # "Extracting" from the heap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def heapify(heap_arr, heap_size, parent_index): | |
# heap_size is just the size of your array (heap_arr). | |
# We are sorting out a family of three, we want the max element to sit at the parent index | |
max_family_idx = parent_index | |
# Compute this parent's children index | |
left_child_idx = 2 * parent_index + 1 | |
right_child_idx = 2 * parent_index + 2 | |
# Find the maximum element in our "3-members" family. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_fans(machine_consumptions, total_initial_consumption, n_fans): | |
# Find the machine that has the largest amount of consumption and the | |
# current total amount of consumption for the company | |
max_index, max_value, current_total_consumption = 0, machine_consumptions[0], 0 | |
for machine_index in range(len(machine_consumptions)): | |
# Compute factory consumption | |
current_total_consumption = current_total_consumption + machine_consumptions[machine_index] | |
# Find worse machine with largest consumption so far | |
if max_value < machine_consumptions[machine_index]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function SimpleWebSocket(address) { | |
if(!("WebSocket" in window)) { | |
console.log("WebSocket NOT supported by your Browser!"); | |
return null | |
} | |
// Let us open a web socket | |
var ws = new WebSocket(address); | |
Originally inspired by https://gist.github.com/cho45/9968462#gistcomment-3522694
import math
SI_PREFIXES_CENTER_INDEX = 8
si_prefixes = ('y', 'z', 'a', 'f', 'p', 'n', 'μ', 'm', '', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
def to_si_notation(value: float, precision: int = 1):
"""Transforms a float number to a string (in SI Notation) using SI prefixes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.from(document.querySelector("#history-app").shadowRoot.querySelector("#history").shadowRoot.querySelectorAll("history-item")).filter((u,i) => i < 17).map(u => u.shadowRoot.querySelector("a").href) |
NewerOlder