Skip to content

Instantly share code, notes, and snippets.

Bark Server self-host

Out of the goodness of their heart, github user Finb gave us three things:

  • the bark ios app
  • the bark apn server
  • their private key that authenticates to the Apple Push Notification (APN) service

The bark server provides an api to push notifications to ios devices it knows about. It can be as simple as a docker container. [Build it yourself][0] or pull it from docker hub.

@djeikyb
djeikyb / Local docker cli, remote docker engine.md
Last active September 5, 2024 20:58
Local docker cli, remote docker engine

Local docker cli, remote docker engine

Local ssh config

Host docker2
  HostName admin-docker-2.example.com
  User ubuntu
  IdentitiesOnly yes
 IdentityFile ~/.ssh/example.pem

Get ssh thumbprint or ssh fingerprint of every entry in known_hosts as json:

ssh-keygen -l -f known_hosts  | awk '{ print "{" "\042host\042:\042" $3 "\042" ",\042thumbprint\042:\042" $2 "\042" ",\042alg\042:\042" $4 "\042" ",\042size\042:\042" $1 "\042" "}"}' | sort | jtbl

formatted:

ssh-keygen -l -f known_hosts \
@djeikyb
djeikyb / InteropCancellationToken.cs
Last active March 1, 2024 18:54
How to cancel a long running native function — from c# — with a CancellationToken!
using System.Runtime.InteropServices;
using System.Threading;
[StructLayout(LayoutKind.Sequential)]
internal struct InteropCancellationToken
{
public InteropCancellationToken(CancellationToken ct)
{
IsCancellationRequested = () => ct.IsCancellationRequested;
}
@djeikyb
djeikyb / MelExtensions.cs
Last active December 22, 2023 01:41
Fluent methods to add scope state key-value pairs to your logs!
using Microsoft.Extensions.Logging;
public static class LogEx
{
public static ScopeStateBuilder<T> With<T>(this ILogger<T> logger, string k, object? v) => new(logger, k, v);
public sealed class ScopeStateBuilder<T> : ILogger<T>
{
private readonly ILogger<T> _logger;
private readonly IDictionary<string, object?> _state = new Dictionary<string, object?>();
@djeikyb
djeikyb / Program.cs
Created October 16, 2023 23:26
Rabbitmq, MassTransit, & the dotnet generic host in a cli program.
using System.ComponentModel.DataAnnotations;
using System.Net.Mime;
using System.Text;
using MassTransit;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@djeikyb
djeikyb / flatten
Last active October 10, 2023 21:04
Turns an appsettings.json into flat json of key-value pairs, or, shell friendly list of plain key-value pairs
#!/bin/sh
toEnvVars() {
toFlatJson "$1" | jq --raw-output '. | to_entries[] | "\(.key)=\(.value)"'
}
toFlatJson() {
# thank you jeff mercado https://stackoverflow.com/a/42303836/659715
jq --arg delim '__' 'reduce (tostream|select(length==2)) as $i ({};
.[[$i[0][]|tostring]|join($delim)] = $i[1]
public static (X509Certificate2, RSA) Read(string publicCert, string privateKeyPemTaggedOrNot)
{
var rsa = RSA.Create();
if (privateKeyPemTaggedOrNot.StartsWith("-----BEGIN RSA PRIVATE KEY-----"))
{
rsa.ImportFromPem(privateKeyPemTaggedOrNot);
}
else
{
var key = Convert.FromBase64String(privateKeyPemTaggedOrNot);
@djeikyb
djeikyb / 20220504.gitconfig
Created May 4, 2023 19:43
current gitconfig
[user]
name = Jacob
email = [email protected]
[alias]
unstage = restore --staged
changelog = log --format='* %s%n%w(,4,4)%+b'
pick = cherry-pick
ll = log --graph --pretty=format:'%C(auto)%h %ad %d %s %C(white)[%aN]' --date='format:%y·%b·%d' --use-mailmap
l = ll --remotes='origin/head' origin/head~5..HEAD
@djeikyb
djeikyb / GitlabClient.cs
Last active December 9, 2022 19:13
Gitlab client with only a couple label endpoints implemented
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
class GitlabClient
{
private readonly HttpClient _client;
public GitlabClient(HttpClient client, string token)