Skip to content

Instantly share code, notes, and snippets.

@karl-gustav
karl-gustav / vue.js
Created May 16, 2018 15:04
An hello world with vue + fetch
<html>
<head></head>
<body>
<section id="app">
<p>{{message}}</p>
<input v-model="message">
</section>
<script src="https://unpkg.com/vue"></script>
<script>
new Vue({
@karl-gustav
karl-gustav / compare_datetime_golang.go
Created May 27, 2018 17:36
Compare two datetimes in golang
package main
import (
"fmt"
"time"
)
func main() {
const layout = "2006-01-02T15:04:05"
time1 := time.Now()
@karl-gustav
karl-gustav / delete.domoticz
Created June 5, 2018 19:43
Delete sensor data from domoticz smart home system
get data:
http://10.0.0.5/json.htm?type=graph&sensor=counter&method=1&idx=611&range=day
delete data:
http://10.0.0.5/json.htm?type=command&param=deletedatapoint&idx=611&date=2018-06-03%2019:55:00
data.result.forEach(point => delete(611, point.d));
function delete(idx, date) {
@karl-gustav
karl-gustav / fix_timezone.sh
Last active September 12, 2018 20:31
Fix timezone/ntp issues raspberry pi
sudo ln -sf /usr/share/zoneinfo/Europe/Oslo /etc/localtime # found in
sudo apt-get purge ntp*
sudo apt-get install chrony
sudo reboot
@karl-gustav
karl-gustav / how_to_install_kiosk_screen.md
Last active September 21, 2018 13:20
How to install kiosk screen raspberry pi

Put 2018-06-27-raspbian-stretch-lite.img on the SD card

Enable ssh:

sudo systemctl enable ssh

Update and install dependencies:

sudo apt-get update

sudo apt-get install \

@karl-gustav
karl-gustav / SVG.css
Created September 24, 2018 08:50
SVG bullet points on lists
li {
list-style-type: none
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><circle style="fill:#A7A7A7;" cx="10" cy="10" r="5"/></svg>')
background-repeat: no-repeat
background-position-y: center
padding-left: 2rem
}
@karl-gustav
karl-gustav / centerCoordinates.js
Created February 7, 2019 07:51
Get center of a list of coordinates
function centerCoordinates(coordinates) {
if (coordinates.length === 0) {
return coordinates;
}
let x, y, z;
x = y = z = 0;
coordinates.forEach(coordinate => {
const latitude = (coordinate[0] * Math.PI) / 180;
@karl-gustav
karl-gustav / Commands.list
Created March 7, 2019 09:36
Super usefull commands
Find encoding of a file: file -i *.fdf
@karl-gustav
karl-gustav / package.json
Created March 15, 2019 09:03
Absolute minimun package.json file
{
"name": "some-name",
"version": "0.0.1",
"dependencies": {
}
}
@karl-gustav
karl-gustav / safeGet.js
Created March 23, 2019 13:39
javascript safe get
function get(obj, ...args) {
let walker = obj;
for (const arg of args) {
if (walker && walker[arg]) {
walker = walker[arg];
} else {
return;
}
}
return walker;