adridoesthings / Opnsense config backup script
0 likes
0 forks
1 files
Last active
An opnsense config backup script which gzip's the config file and encrypts it with gpg. Just change the first variables to your configuration specific. Then you can run this script with cronjob for example.
1 | #!/bin/bash |
2 | set -eeuo pipefail |
3 | |
4 | # your configuration constants |
5 | # generate key and secret on /ui/auth/user |
6 | OPNSENSE_URL="https://opnsense.yournetwork.lan" |
7 | OPNSENSE_KEY="" |
8 | OPNSENSE_SECRET="" |
9 | GPG_RECIPIENT="" |
10 | BACKUP_DESTINATION="./backups" |
adridoesthings / Traffic light written in Verilog
0 likes
0 forks
1 files
Last active
Disclaimer: I don't speak Verilog, actually I speak VHDL
1 | module top ( |
2 | input clk, |
3 | input rst, |
4 | output reg red, |
5 | output reg yellow, |
6 | output reg green |
7 | ); |
8 | |
9 | localparam CLK_CYCLES_PER_SECOND = 27000000; |
adridoesthings / Homeassistant Unifi AP Led Configuration
0 likes
0 forks
1 files
Last active
Toggle your unifi access point led with homeassistant. Create a homeassistant helper (toggle) named input_boolean.unifi_ap_led for example and create an automation that runs this shell script when the state of the helper toggle changes. Place your id_ed25519 key in config/.ssh/id_ed25519.
1 | shell_command: |
2 | unifi_ap_led_update: ssh -o StrictHostKeyChecking=no USERNAME@UNIFI_AP_IP -i ./.ssh/id_ed25519 "sed -i 's/^mgmt\.led_enabled=.*/mgmt\.led_enabled={% if is_state("input_boolean.unifi_ap_led", "on") %}true{% else %}false{% endif %}/' /var/etc/persistent/cfg/mgmt && echo {% if is_state("input_boolean.unifi_ap_led", "on") %}1{% else %}0{% endif %} > /proc/gpio/led_pattern" |
adridoesthings / Follow
0 likes
0 forks
1 files
Last active
This program will print the content of a file and then waits for a change of the file and prints the added content.
1 | /* |
2 | * This program will print the content of a file and then waits for a change of the file and prints the added content. |
3 | * Author: AdriDoesThings <adri@adridoesthings.com> |
4 | */ |
5 | |
6 | #include <stdint.h> |
7 | #include <stdio.h> |
8 | #include <stdlib.h> |
9 | #include <string.h> |
10 | #include <unistd.h> |
adridoesthings / ZFind
0 likes
0 forks
1 files
Last active
Find a pattern in a file, print the content of the file and mark the position of the pattern (if found)
1 | const std = @import("std"); |
2 | |
3 | const COLOR_RED = "\x1b[0;31m"; |
4 | const COLOR_RESET = "\x1b[0m"; |
5 | |
6 | fn print_usage(exec: [*:0]u8) void { |
7 | std.debug.print("Usage: {s} FILE PATTERN\n", .{exec}); |
8 | } |
9 | |
10 | fn string_contains_substring(allocator: std.mem.Allocator, string: []u8, substring: []u8) !std.ArrayList([2]usize) { |
adridoesthings / Unlimited download
0 likes
0 forks
1 files
Last active
This is a http server that serves a infinitely big file filled with random content
1 | const std = @import("std"); |
2 | const eql = std.mem.eql; |
3 | |
4 | pub const std_options = .{ |
5 | .log_level = .info, |
6 | }; |
7 | |
8 | fn http_error(writer: std.net.Stream.Writer, status_code: u16) !void { |
9 | const status = switch (status_code) { |
10 | 200 => "OK", |
Newer
Older