Skip to content

Instantly share code, notes, and snippets.

View ddjerqq's full-sized avatar
🐙
말보다는 행동이지

ddjerqq

🐙
말보다는 행동이지
  • Stack, Heap
View GitHub Profile
@ddjerqq
ddjerqq / vector_add.cu
Last active January 20, 2023 22:30
simple vector addition code for CUDA. with rich comments
#include <chrono>
#include "../common/book.h"
#define N (1 << 16)
// element count: 65536
// max blocks -> 65535
// max threads per block -> 512
using namespace std;
@ddjerqq
ddjerqq / ripple.cu
Created January 21, 2023 20:02
CUDA ripple effect on the GPU, with measured frames and BLOCK explanation comment for help with indexing.
#include <chrono>
#include "../common/book.h"
#include "../common/cpu_anim.h"
#define DIM 1024
using namespace std;
using namespace std::chrono;
// 2D array of blocks and dimensions
@ddjerqq
ddjerqq / sha256.cuh
Last active August 9, 2024 19:02
CUDA C++ SHA256
#include <cstring>
#include <sstream>
#include <iomanip>
#ifndef SHA256_CUH
#define SHA256_CUH
#include <string>
#include <array>
@ddjerqq
ddjerqq / cuINDEX.md
Last active March 6, 2023 10:46
this is a small helper for indexing blocks and threads with cuda.

CUDA helper for block and thread indexing

general rule of thumb

threadsperblock = 32
blockspergrid = (an_array.size + (threadsperblock - 1)) // threadsperblock
increment_by_one[blockspergrid, threadsperblock](an_array)
@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
@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 / 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 / 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 / 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 / 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; }