Skip to content

Instantly share code, notes, and snippets.

View ngerakines's full-sized avatar
🏠
Working from home

Nick Gerakines ngerakines

🏠
Working from home
View GitHub Profile
@ngerakines
ngerakines / string_or_enum_json.rs
Last active November 11, 2024 15:20
Rust plaground code that parses json value as string or complex enum
use std::str::FromStr;
use std::fmt;
use std::marker::PhantomData;
use anyhow::anyhow;
use serde::{Deserialize, Serialize, Deserializer};
use serde::de::{self, Visitor, MapAccess};
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "type")]
pub enum FeedQuery {
[package]
name = "corpfeeds"
version = "0.1.0"
edition = "2021"
[dependencies]
futures-util = { version = "0.3.31", features = ["sink"] }
http = "1.1.0"
serde = { version = "1.0.214", features = ["derive"] }
serde_json = "1.0.132"
{
storage file_system ./caddy/
debug
pki {
ca pyroclastic {
name "Pyroclastic Cloud"
}
}
}
1 001
2 002
3 003
4 004
5 005
6 006
7 007
8 008
9 009
10 00A
@ngerakines
ngerakines / README.md
Last active August 27, 2024 19:57
Blue Badge signing in Python

Badge Signing Demo

This script demonstrates badge signing.

  1. Create a environment to run the script:

    $ python -m venv venv
    $ . ./venv/bin/activate
    
  2. Install the required dependencies

package main
import (
"fmt"
"time"
"github.com/carlmjohnson/crockford"
)
func encodeInt64(value int64) string {
@ngerakines
ngerakines / README.md
Last active February 23, 2024 20:10
Running your own atproto pds

README

First, understand a few things:

  1. Every identity has a unique did (distributed identifier) that looks like this: did:plc:cbkjy5n7bk3ax2wplmtjofq2

  2. You can alias a domain to your did.

    dig +short TXT _atproto.ngerakines.me
    "did=did:plc:cbkjy5n7bk3ax2wplmtjofq2"
    
@ngerakines
ngerakines / _etc_nginx_nginx.conf
Created December 15, 2020 20:13
Integrate your Pleroma blocklist with nginx (replace _ with / for original filenames)
# Your main nginx config file.
http {
# Existing configuration…
# Enable blocks based on IPs used by Fediverse instance domain names.
include /etc/nginx/blocklist-ip.conf;
}
package main
import (
"bufio"
"encoding/json"
"fmt"
"net/http"
"os"
"github.com/kr/pretty"
// (c) 2019 Nick Gerakines
// This code is licensed under MIT license
#include <signal.h>
#include <thread>
#include <chrono>
#include "cpprest/http_listener.h"
using namespace std;
using namespace web;