Skip to content

Instantly share code, notes, and snippets.

View ddjerqq's full-sized avatar
🙇‍♂️
I hit my head

ddjerqq

🙇‍♂️
I hit my head
View GitHub Profile
@ddjerqq
ddjerqq / blog.md
Last active April 27, 2024 19:35
A blog written for Blazorise

How to create a ShareButton component with Blazorise!

Are you ready to sprinkle some Blazorise magic into your Blazor app?
Adding share buttons for social media platforms can give your users an easy
way to spread the word about your awesome content. It's easier than you think, thanks to Blazorise!

image


@ddjerqq
ddjerqq / dependency-injection.py
Created January 13, 2024 07:45
python dependency injection using dependency-injector package
import os
import sys
import logging
import sqlite3
from typing import Dict
from dependency_injector.wiring import Provide, inject
from dependency_injector import containers, providers
@ddjerqq
ddjerqq / Mediator.py
Created January 13, 2024 07:40
python very simple mediator usage
import asyncio
import time
from typing import TypeVar
from mediatr import Mediator, GenericQuery
T = TypeVar("T")
class BaseQuery(GenericQuery[T]):
@ddjerqq
ddjerqq / Rfc6238.cs
Last active November 13, 2023 17:15
TOTP: Time-Based One-Time Password Algorithm Implementation in C#
using System.Security.Cryptography;
namespace Rfc6238;
public enum HmacAlgo
{
Sha1,
Sha256,
Sha512,
}
@ddjerqq
ddjerqq / PrivateKey.cs
Created September 29, 2023 17:03
C# implementation and easy abstraction for RSA cryptographic encryption algorithm
using System.Security.Cryptography;
using Newtonsoft.Json;
namespace Crypto;
public struct PrivateKey
{
private byte[] D { get; init; }
private byte[] P { get; init; }
@ddjerqq
ddjerqq / Sha256.cs
Created August 17, 2023 22:49
ILGPU implementation of SHA256 on the GPU
#pragma warning disable CS0649
using ILGPU;
using ILGPU.Runtime;
namespace Hasher;
public unsafe struct Sha256
{
/**************************** VARIABLES *****************************/
@ddjerqq
ddjerqq / AsyncQueue.cs
Created August 7, 2023 19:57
A thread-safe asynchronous queue.
using System.Threading.Tasks.Dataflow;
namespace AsyncQueue;
/// <summary>
/// A thread-safe asynchronous queue.
/// </summary>
/// <example>
/// <code>
/// var queue = new AsyncQueue`int();
@ddjerqq
ddjerqq / Diamond.JwtManager.cs
Last active July 25, 2023 12:34
digital signature for web API security
using System.Security.Claims;
using System.Text;
using System.IdentityModel.Tokens.Jwt;
using Microsoft.IdentityModel.Tokens;
namespace Diamond;
public static class JwtTokenManager
{
@ddjerqq
ddjerqq / README.MD
Last active June 22, 2023 14:52
The hash ring, used for distributing items evenly across shards / threads / processes

Hash Ring

the hash ring, use this to distribute items evenly accross shards / threads / processes

     *  0  *
   *         *
 *             *
270            90
 * *
@ddjerqq
ddjerqq / discord-timestamps.md
Created March 17, 2023 10:04 — forked from LeviSnoot/discord-timestamps.md
Discord Timestamp Syntax

Discord Timestamps

Discord timestamps can be useful for specifying a date/time across multiple users time zones. They work with the Unix Timestamp format and can be posted by regular users as well as bots and applications.

The Epoch Unix Time Stamp Converter is a good way to quickly generate a timestamp. For the examples below I will be using the Time Stamp of 1543392060, which represents November 28th, 2018 at 09:01:00 hours for my local time zone (GMT+0100 Central European Standard Time).

Formatting

Style Input Output (12-hour clock) Output (24-hour clock)
Default <t:1543392060> November 28, 2018 9:01 AM 28 November 2018 09:01