Skip to content

Instantly share code, notes, and snippets.

View kdbrian's full-sized avatar
🎵
Self Aware

Takumi (artisan) kdbrian

🎵
Self Aware
View GitHub Profile
@kdbrian
kdbrian / Main.c
Created October 29, 2026 09:11
Handling strings in C is not a native behavior, by the help of stdlib the experience gets better.
//check out blog
// https://medium.com/@briankidiga.dev/ctrings-ffa556e69ff3
#include<stdio.h>
#include "Main.h"
int main(int argc, char* argv[])
{
printf("Enter name : ");
char n[64];
@kdbrian
kdbrian / README.md
Created July 29, 2026 12:53
Algorithm Visualizer

Algorithm Visualizer

Introduction

Welcome to Algorithm Visualizer, an interactive online platform designed to bring algorithms to life through visualization. Whether you're a student, teacher, or professional, our platform provides an engaging way to explore and understand various algorithms.

GitHub contributors GitHub license

Languages and Frameworks Used

Languages

@kdbrian
kdbrian / DateUtils.kt
Created October 14, 2025 06:10
Utilities for dates in Kotlin
package com.example
import java.text.SimpleDateFormat
import java.time.LocalDate
import java.time.ZoneId
import java.util.Date
import java.util.Locale
object DateUtils {
@kdbrian
kdbrian / KeyGen.py
Created December 14, 2024 23:40
Generating a random 256 bit key with Python
import os
key = os.urandom(32).hex()
print(key)
@kdbrian
kdbrian / ErrorHandler.kt
Created December 11, 2024 19:22
Am having an error wrapper class over the normal Exception interface, with this I can parse errors and handle them for a better response , for example the Socket timeout exception which is common in most network requests.
sealed class AppError(
override val message: String? = null
) : Exception(){
data object SocketTimeOutError : AppError("Failed to connect, please check your internet connection and retry.")
}
@kdbrian
kdbrian / MainViewModelFactory.kt
Created December 10, 2024 03:41
A viewmodel factory, can be used to provision a viewmodel from a kotlin application that has lifecycle.
@Suppress("UNCHECKED_CAST")
class MainViewModelFactory(val application: Application) : ViewModelProvider.Factory {
override fun <T : androidx.lifecycle.ViewModel> create(modelClass: Class<T>): T {
return MainViewModel(application) as T
}
}
//example of usage in a composable
LocalViewModelStoreOwner.current?.let {
@kdbrian
kdbrian / JwtService.java
Last active December 10, 2024 03:42
An abstraction of spring security methods to interact with the jwt, requires the libraries jjwt-api jjwt-impl jjwt-jackson The implementation is really similar but can be customized
public interface JwtService {
final String SECRET_KEY = "";
String generateToken(
Map<String, Object> extraClaims,
UserDetails userDetails
);