Skip to content

Instantly share code, notes, and snippets.

View dommyrock's full-sized avatar

Dominik Polzer dommyrock

View GitHub Profile
# Check your current git config
git config --global --list
git config --list
# Update your name and email config
# (email has to be one of the listed ones under your github accont
# https://github.com/settings/emails
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
@dommyrock
dommyrock / v3.toml
Created March 29, 2025 19:56
TOML Alternative to Pulsar YAML RuleEngine
# Title: Ssh Backdoor Log
# Creation date: 2020/12/21
# MITRE ATT&CK Tactic: TA0006 - Credential Access - https://attack.mitre.org/tactics/TA0006/
# MITRE ATT&CK Technique: T1556 - Modify Authentication Process - https://attack.mitre.org/techniques/T1556/
# Source
# https://github.com/exein-io/pulsar/blob/main/rules/credential_access/ssh_backdoor_log.yaml
# Docs
# https://toml.io/en/v1.0.0#array-of-tables
# By default Reload config with < shft + cmd + , >
# UI
theme = rose-pine
background = 1C2021
background-opacity = 0.95
background-blur-radius = 20
font-family = JetBrainsMonoNL Nerd Font
font-size = 20
@dommyrock
dommyrock / Rust - Prometheus Recorder setup
Created September 11, 2024 10:28
Basic Prometheus setup for Rust
use anyhow::{Context, Error};
use metrics_exporter_prometheus::{Matcher, PrometheusBuilder, PrometheusHandle};
pub const OP_LABEL: &str = "op";
pub const METRICS_NAME: &str = "myapp_request_duration_seconds";
/// Sets up the Prometheus metrics recorder.
pub fn setup_metrics_recorder() -> Result<PrometheusHandle, Error> {
const BUCKETS: &[f64] = &[
0.001, 0.002, 0.003, 0.004, 0.005, 0.01, 0.015, 0.02, 0.025, 0.03, 0.035, 0.04, 0.045,
@dommyrock
dommyrock / lifetime_intro.rs
Created June 30, 2024 13:46
Rust Lifetime intro
//Doesn't compile > error: lifetime may not live long enough
fn main() {
println!("Hello, world!");
}
fn two_refs(vec:&mut Vec<&str>,str: &str ){
vec.push(str);
}
//Because of the lifetime elision. Compiler introduced 3 different lifetimes
fn two_refs<'a,'b,'c>(vec:&'a mut Vec<&'b str>,str: &'c str ){
@dommyrock
dommyrock / gist:1eff6692779be62d50c2904d552f5f12
Created March 9, 2024 21:13
Rust Allign a value to the length of a cache line
/// Pads and aligns a value to the length of a cache line.
///Source :https://github.com/ibraheemdev/seize/blob/master/src/utils.rs
#[cfg_attr(
any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "powerpc64",
),
repr(align(128))
)]
<policies>
<inbound>
<cors allow-credentials="false">
<allowed-origins>
<origin>YOUR-DOMAIN</origin>
</allowed-origins>
<allowed-methods preflight-result-max-age="300">
<method>GET</method>
<method>POST</method>
<method>PATCH</method>
<policies>
<inbound>
<base />
<set-backend-service id="apim-generated-policy" backend-id="YOUR-SERVICE-ID" />
<rate-limit-by-key calls="5" renewal-period="300" counter-key="@(context.Request.IpAddress)" />
<set-header name="Authorization" exists-action="append">
<value>Berer TOKEN-VALUE</value>
</set-header>
</inbound>
<backend>
<policies>
<inbound>
<base />
<set-backend-service id="apim-generated-policy" backend-id="YOUR-BACKEND-SERVICE-ID" />
<quota-by-key calls="1000" renewal-period="2505600" counter-key="@(context.Subscription?.Key ?? "anonymous")" increment-condition="@(context.Response.StatusCode >= 200 && context.Response.StatusCode < 300)" />
<set-header name="Authorization" exists-action="append"><value>Berer TOKEN-VALUE</value></set-header>
</inbound>
<backend>
<base />
</backend>
//Builds <style> based on theme arg
func htmlStleBuilder() string {
args := os.Args
switch len(args) {
case 3:
if args[2] == "mid" {
return static.HtmlOpen + static.Root_midTheme + static.HtmlMid
}
return static.HtmlOpen + static.Root_darkTheme + static.HtmlMid
default: