Skip to content

Instantly share code, notes, and snippets.

View dlford's full-sized avatar

Dan Ford dlford

View GitHub Profile
@dlford
dlford / mikrotik_backups.sh
Last active March 10, 2024 18:23
A bash script to backup multiple MikroTik devices all at once
#!/bin/bash
set -euo pipefail
# MikroTik Multi-Device Backup Script
#
# Copyright 2024 DL Ford
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARI
{
"SVComponent": {
"prefix": "svcomponent",
"body": [
"import React, { forwardRef } from 'react';",
"",
"import ErrorBoundary from '../ErrorBoundary';",
"import { SVComponent } from '../../types/shared';",
"import { getClasses } from '../../lib/componentLib';",
"",
@dlford
dlford / cloudflare_ddns.rsc
Last active September 18, 2023 14:41
MikroTik RouterOS Cloudflare DDNS with API Token
# Create a token with DNS edit and read permissions on all zones - https://dash.cloudflare.com/profile/api-tokens
# Get zoneid from https://dash.cloudflare.com/ => select a domain => Overview => API => Zone ID
# Get DNS record id:
# curl --request GET \
# --url https://api.cloudflare.com/client/v4/zones/{zoneid}/dns_records \
# --header 'Content-Type: application/json' \
# --header 'Authorization: Bearer {api_token}'
# --- config ---
@dlford
dlford / example.html
Last active September 6, 2023 16:41
Chromium Bug 1479494 Demo Code
<html>
<head>
<style>
:where(.modal) {
margin: 0;
padding: 0;
inline-size: 100%;
max-inline-size: 100%;
block-size: 100%;
max-block-size: 100%;
@dlford
dlford / main.go
Created August 24, 2023 01:13
Fixed Go code
package main
import (
"encoding/json"
"fmt"
)
// Comment from Database
type Comment struct {
ID string `json:"id"`
@dlford
dlford / out.txt
Created August 23, 2023 23:30
JS example output
[
{
"id": "131cf4bb-1971-43a2-992f-2cbb042a4184",
"pid": "",
"text": "comment 2",
"children": [
{
"id": "4c93a789-ecab-4173-954c-b039cd3a9e17",
"pid": "131cf4bb-1971-43a2-992f-2cbb042a4184",
"text": "comment 3"
@dlford
dlford / out.txt
Created August 23, 2023 23:30
Go example output
[
{
"id": "fe78ce24-c2c8-4d00-b96d-8b8be9ce0f06",
"pid": "",
"text": "comment 30"
},
{
"id": "bad87461-3cbf-4ecb-a8c7-36876b57d652",
"pid": "",
"text": "comment 9",
@dlford
dlford / main.js
Created August 23, 2023 23:28
Example JS Code
const datajson = `[{"id":"f1c3a838-f4b4-4ebd-bb1b-d3e4c0dce27d","pid":"6a162b3f-9341-46e9-95f7-dedc6cd06868","text":"comment 1"},{"id":"131cf4bb-1971-43a2-992f-2cbb042a4184","pid":"","text":"comment 2"},{"id":"4c93a789-ecab-4173-954c-b039cd3a9e17","pid":"131cf4bb-1971-43a2-992f-2cbb042a4184","text":"comment 3"},{"id":"c7974b6d-67e1-47d0-84fa-c78d51682df2","pid":"131cf4bb-1971-43a2-992f-2cbb042a4184","text":"comment 4"},{"id":"386c4439-4596-47c1-99bf-cb479055fe5a","pid":"","text":"comment 5"},{"id":"5ef0816e-ea13-4a7e-8009-e67ee08ef906","pid":"386c4439-4596-47c1-99bf-cb479055fe5a","text":"comment 6"},{"id":"96b0a536-602b-4f3f-a352-020f22cdfb18","pid":"","text":"comment 7"},{"id":"d0f11e98-deea-4fd5-becb-8f406ebcae83","pid":"96b0a536-602b-4f3f-a352-020f22cdfb18","text":"comment 8"},{"id":"bad87461-3cbf-4ecb-a8c7-36876b57d652","pid":"","text":"comment 9"},{"id":"e3ee6f90-495f-4348-9c29-bd6e15ec3b39","pid":"bad87461-3cbf-4ecb-a8c7-36876b57d652","text":"comment 10"},{"id":"6a162b3f-9341-46e9-95f7-dedc6cd06868","pi
@dlford
dlford / main.go
Created August 23, 2023 23:27
Example Go Code
package main
import (
"encoding/json"
"fmt"
)
// Comment from Database
type Comment struct {
ID string `json:"id""`