Skip to content

Instantly share code, notes, and snippets.

@Bas-Man
Bas-Man / keybase.md
Created October 23, 2022 05:20
KeyBase Proof

Keybase proof

I hereby claim:

  • I am Bas-Man on github.
  • I am basman (https://keybase.io/basman) on keybase.
  • I have a public key ASCnFgOVrIuO3aoI322zwdy49mb9r5GlyegTo5Lmd1X7Kwo

To claim this, I am signing this object:

@Bas-Man
Bas-Man / spf_a_mechanism_regex.rs
Created April 20, 2021 14:44
Regex to match Mechanism type A for SPF using Rust
fn main() {
let regex = regex::Regex::new(r"(?P<a_only>a$)|(?:a:)(?P<a_colon>[^/].+)|(?P<a_slash>a/\d{1,2})").unwrap();
[
"a",
"a:example.com",
"a:mailers.example.com",
"a/24",
"a:offsite.example.com/24]",
]
@Bas-Man
Bas-Man / using_regex_set.rs
Created April 20, 2021 13:37
Applying multiple regex patterns against a string to see which one matches
use regex::{Regex, RegexSet};
fn main() {
let string1 = "a:test";
let string2 = "a/24";
let string3 = "a";
let string4 = "a:test/24";
// Create a RegexSet
let regex_set = RegexSet::new(&[r"(a$)", r"a:(.*)", r"a(/\d{1,2})"]).unwrap();
@Bas-Man
Bas-Man / txt.rs
Created March 28, 2021 14:06
trust-dns-resolver looking up TXT records in Rust
use trust_dns_resolver::error::ResolveResult;
use trust_dns_resolver::Resolver;
use trust_dns_resolver::{config::*, lookup::TxtLookup};
fn main() {
// Construct a new Resolver with default configuration options
let resolver = Resolver::new(ResolverConfig::default(), ResolverOpts::default()).unwrap();
// Lookup the IP addresses associated with a name.
// The final dot forces this to be an FQDN, otherwise the search rules as specified
@Bas-Man
Bas-Man / soa.rs
Last active March 26, 2021 08:03
trust-dns-resolver looking up SOA records in Rust
use trust_dns_resolver::error::ResolveResult;
use trust_dns_resolver::Resolver;
use trust_dns_resolver::{config::*, lookup::SoaLookup};
fn main() {
// Construct a new Resolver with default configuration options
let resolver = Resolver::new(ResolverConfig::default(), ResolverOpts::default()).unwrap();
let soa_response = resolver.soa_lookup("gmail.com.");
@Bas-Man
Bas-Man / main.rs
Last active March 26, 2021 07:39
trust-dns-resolver looking up MX records in Rust
use trust_dns_resolver::config::*;
use trust_dns_resolver::Resolver;
// Note you should add the crate to your Cargo.toml file
// trust-dns-resolver = "0.20.1"
fn main() {
// Construct a new Resolver with default configuration options
let resolver = Resolver::new(ResolverConfig::default(), ResolverOpts::default()).unwrap();
@Bas-Man
Bas-Man / regex-japanese.txt
Created January 5, 2021 02:08 — forked from terrancesnyder/regex-japanese.txt
Regex for Japanese
Regex for matching ALL Japanese common & uncommon Kanji (4e00 – 9fcf) ~ The Big Kahuna!
([一-龯])
Regex for matching Hirgana or Katakana
([ぁ-んァ-ン])
Regex for matching Non-Hirgana or Non-Katakana
([^ぁ-んァ-ン])
Regex for matching Hirgana or Katakana or basic punctuation (、。’)
@Bas-Man
Bas-Man / email-parse-subject.py
Last active October 15, 2020 11:14
Extract Email Subject Line, Single line only support.
import email.parser
from email import policy
def openFromFile(fp) -> email.message.EmailMessage:
"""
Read in the open file pointer
:param fp: file pointer to open file.
:type fp: file pointer
:returns: msg which is an email.message.EmailMessage
@Bas-Man
Bas-Man / cookie.js
Created July 15, 2020 13:38
HUGO Cookie Footer JS
@Bas-Man
Bas-Man / cookie.css
Created July 15, 2020 13:36
HUGO Cookie Footer CSS