Example output and NodeJS server code snippet for a Froggit weather station when using an own custom server instead of predefined weather services.
My hardware:
- WH3000SE sensor
- DP1500 Dongle
#!/bin/bash | |
# Creates time series dummy data in a CSV with random hourly values. | |
# | |
# timeseries: array of name|from|to for the time series | |
# -> name: name of the series (string) | |
# -> from: lower limit of the hourly values (number) | |
# -> to: upper limit of the hourly values (number) | |
# amount: number of hourly values to create for each series, 24 for one complete day, 24*365 for a year etc. | |
# startdate: date-time of the first hour |
# save as ./github/workflows/git-ci-build.yml | |
# make sure that 'test-coverage' generates the coverage reports (lcov) | |
name: git-ci-build | |
on: | |
[push] | |
jobs: | |
build: |
// In the example: sort descending by 'activeUsers' attribute of the value object | |
var countries = new Map(); | |
countries.set('DE', { name: 'Germany', activeUsers: 15000 }); | |
countries.set('PL', { name: 'Poland', activeUsers: 13900 }); | |
countries.set('UK', { name: 'United Kingdom', activeUsers: 14500 }); | |
console.log('without iterator:'); | |
for (let [key, info] of countries) { |
var express = require("express"); | |
var app = express(); | |
const setMyInfo = (text) => { | |
return (req, res, next) => { | |
req.myInfo = text; | |
next(); | |
}; | |
}; |
Sometimes an update of the kernel breaks your current grub2. You will see an error like /usr/bin/grub2-editenv: error: invalid environment block
during execution of the update procedure.
In that case don't restart your machine because it is most likely that this will fail and then you'll have to fix it using chroot from a Live Media. Instead, immediately after the update showing up the error, fix it by executing the following as root:
dnf reinstall grub2-efi-x64 shim-x64
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
A simple setup for using nginx to avoid CORS errors during local development without the need of code changes.
Let's assume you are developing a frontend and a backend service belonging together. It's a good practice to have those two projects separated to decouple development, deployment, patching etc.
At the end, both parts mostly would run under one domain but in different contexts, e.g.:
Small functional React component for counting numbers up to a certain value in a specified duration in ms. Useful for creating animated dashboards etc.
Uses React hooks useEffect
, useState
and useRef
. Good example on how to pass props to a useEffect
hook without declaring them as dependencies and how to deal with setInterval
in functional components.
<CounterFunc countFrom={0} countTo={123} durationMs={400} />
An instance template with more than one NIC obviously can't be created in the GCP web console. But it could easily be achieved using the gcloud
CLI with consecutive --network-interface
options.
gcloud compute --project=YOUR_PROJECT instance-templates create multi-nic-vm-template --machine-type=e2-micro --network-interface=subnet=projects/YOUR_PROJECT/regions/europe-west3/subnetworks/my-subnet-1,no-address --network-interface=subnet=projects/YOUR_PROJECT/regions/europe-west3/subnetworks/my-subnet-2,no-address --maintenance-policy=MIGRATE --image=my-image-1 --image-project=YOUR_PROJECT --boot-disk-size=10GB --boot-disk-type=pd-standard --boot-disk-device-name=instance-template-1 --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --reservation-affinity=any --tags=allow-health-check
In this example I specified two subnets that belong to different VPC's.