Skip to content

Instantly share code, notes, and snippets.

View frederik-hoeft's full-sized avatar
🐧
Working on @PrySec

Frederik Höft frederik-hoeft

🐧
Working on @PrySec
View GitHub Profile
@frederik-hoeft
frederik-hoeft / .editorconfig
Last active August 30, 2024 15:40
C# editorconfig
# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true
# C# files
[*.cs]
#### Core EditorConfig Options ####
# Indentation and spacing
indent_size = 4
@frederik-hoeft
frederik-hoeft / vlan-access-mode-down.sh
Last active August 7, 2023 19:43
Cisco-style VLAN access mode interfaces for Linux routers using traffic control
#!/bin/sh
iface=''
vlan=-1
while getopts 'i:v:' opt; do
case ${opt} in
i)
iface="${OPTARG}"
;;
@frederik-hoeft
frederik-hoeft / BranchlessMp3HeaderValidationOneLiner.md
Created May 30, 2022 11:42
absolutely no one asked for it, but you get it anyways :)
static bool IsValidHeader(void* pFrame) => (unchecked((int)TRUE) & ((-(int)((MpegVersion)((*(((byte*)pFrame) + 1) & 0x18) >> 3) ^ MpegVersion.Reserved)) >> 31) & ((-(int)(MpegLayer)((*(((byte*)pFrame) + 1) & 0x06) >> 1)) >> 31) & (-((*(((byte*)pFrame) + 2) & 0xF0) >> 4 ^ 15) >> 31) & (-BitRates[((int)(MpegVersion)((*(((byte*)pFrame) + 1) & 0x18) >> 3) & 0x1) ^ (((int)(MpegVersion)((*(((byte*)pFrame) + 1) & 0x18) >> 3) & 0x2) >> 1), (int)(MpegLayer)((*(((byte*)pFrame) + 1) & 0x06) >> 1), (*(((byte*)pFrame) + 2) & 0xF0) >> 4] >> 31) & (-((*(((byte*)pFrame) + 2) & 0xF0) >> 4 ^ 3) >> 31) & (~((-(int)((ChannelMode)((*(((byte*)pFrame) + 3) & 0xC0) >> 6) ^ ChannelMode.JointStereo) >> 31) & (-((*(((byte*)pFrame) + 3) & 0x30) >> 4) >> 31))) & (~((MAX_FRAME_SIZE - ((((SamplesPerFrame[((int)(MpegVersion)((*(((byte*)pFrame) + 1) & 0x18) >> 3) & 0b01) ^ (((int)(MpegVersion)((*(((byte*)pFrame) + 1) & 0x18) >> 3) & 0x2) >> 1), (int)(MpegLayer)((*(((byte*)pFrame) + 1) & 0x06) >> 1)] >> 3) * BitRates[((int)(MpegVers
@frederik-hoeft
frederik-hoeft / .View
Created September 28, 2021 10:11 — forked from aspnetde/.View
Xamarin.iOS MemoryUtility
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.MessageUI;
using MonoTouch.UIKit;
namespace MyApp
{
public interface ICanCleanUpMyself
{

Email regex (from .NET source code)

const string emailRegex = @"^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900
@frederik-hoeft
frederik-hoeft / AspNetCoreIdentityMySQL.sql
Last active June 2, 2021 12:03
AspNetCore Identity create table statements for MySQL (validated from Microsoft.AspNetCore.Identity source code)
CREATE TABLE `AspNetUsers` (
-- is UUID
`Id` VARCHAR (36) NOT NULL,
`AccessFailedCount` INT NOT NULL,
-- user.ConcurrencyStamp = Guid.NewGuid().ToString();
`ConcurrencyStamp` VARCHAR (36) NULL,
`Email` VARCHAR (256) NULL,
`EmailConfirmed` BIT NOT NULL,
`LockoutEnabled` BIT NOT NULL,
`LockoutEnd` TIMESTAMP NULL,