Skip to content

Instantly share code, notes, and snippets.

View tobz's full-sized avatar
💁‍♂️
it me

Toby Lawrence tobz

💁‍♂️
it me
View GitHub Profile
use std::{mem::ManuallyDrop, ops::Deref, slice::from_raw_parts, str::from_utf8_unchecked};
use crate::interning::InternedString;
const OWNED_PTR_TAG: usize = 0xFF00_0000_0000_0000;
#[repr(C)]
#[derive(Clone, Copy)]
struct OwnedUnion {
cap: usize, // Field one.
loom::model(|| {
// These lines are purely to set up the necessary data structures:
let interner = FixedSizeInterner::new(NonZeroUsize::new(1024).unwrap());
let t1_interned_s = interner.try_intern(STRING_TO_INTERN).expect("should not fail to intern");
assert_eq!(t1_interned_s.deref(), STRING_TO_INTERN);
// Now we spawn our second thread, meant to run concurrently with our "first" thread, which is the code
// that comes _after_ the call to `loom::thread::spawn`:
let t2_result = loom::thread::spawn(move || {
interner.try_intern(STRING_TO_INTERN).expect("should not fail to intern")
/// Atomic smart pointer that supports replacing itself.
///
/// ## Metric handles and expiration
///
/// In metric handles, we have to deal with the potential that a registry expires a metric, which
/// could otherwise leave a handle attached to a metric that is reported nowhere. In order to handle
/// this, we need the ability to be able to reset/update the internal field that holds the smart
/// pointer reference to the inner data, which requires a mechanism for interior mutability given
/// the immutable references by which handles are accessed through.
///
[package]
name = "quanta-stdlib-deviation"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
quanta = "0.12.1"
hdrhistogram = "7.5.4"
#!/usr/bin/env sh
set -euo pipefail
ACME_SH_HOME="/data/acme.sh"
ACME_SERVER="https://acme.zerossl.com/v2/DV90"
contains() {
if [ "$1" ] && [ "$2" ] && [ -z "${1##*"$2"*}" ];
then
@tobz
tobz / steps.md
Last active September 5, 2024 08:11
Migrate Radarr from SQLite to Postgres

Migration steps

  1. Upgrade Radarr to at least v4.1.0.6133 or newer. This brings in support for Postgres. This will also ensure that all of your SQLite tables have the latest schema migrations applied before we migrate to Postgres. If you want to upgrade further, that's fine too, but make sure you've completed all upgrades first before continuing.
  2. Create your Postgres databases (one for the "main" database and one for the "logs" database) and configure Radarr with the relevant Postgres credentials. Both databases need to be owned by/accessible from the same Postgres user.
  3. Restart Radarr, and ensure it connects to Postgres and runs all schema migrations.
  4. Once all schema migrations have been applied, and no other activity is occurring, stop Radarr.
  5. Copy the SQLite databases from the Radarr instance/pod, both the main database and logs database. For this guide, we'll assume these files are called radarr.db and logs.db.
  6. Using pg_dump -s, dump the schema for the main Radarr database . P
with defaults: Some(Array [String("*")])
with multiple_outputs=true: Some(Array [String("logs"), String("metrics"), String("traces")])
with multiple_outputs=true, disable_traces=true: Some(Array [String("logs"), String("metrics")])
def find_nested_object_property_schema(schema, property_name)
@logger.debug "Starting search for nested property '#{property_name}'"
@logger.debug "Starting schema: #{JSON.dump(get_reduced_schema(schema))}"
# See if we're checking an object schema directly.
if !schema['properties'].nil?
@logger.debug "Schema is object, checking properties directly."
return schema['properties'][property_name]
end
@tobz
tobz / Dockerfile
Last active December 21, 2022 06:04
FROM ghcr.io/goauthentik/server:2022.9.0
USER root
RUN sed -i -e 's# > /dev/stderr##g' /lifecycle/ak
USER authentik
ENTRYPOINT ["/lifecycle/ak"]
CMD ["server"]
---
version: '3.4'
services:
postgresql:
image: docker.io/library/postgres:12-alpine
restart: unless-stopped
network_mode: host
healthcheck:
test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]