Skip to content

Instantly share code, notes, and snippets.

View R-uan's full-sized avatar
💤
Learning

Ruan R-uan

💤
Learning
View GitHub Profile
@R-uan
R-uan / audio_archive_compose.yaml
Last active March 24, 2026 11:44
Docker Compose to build the fullstack audio-archive.
services:
frontend:
build:
context: ./audio-archive-frontend
args:
- NEXT_PUBLIC_API_URL=http://localhost:5000/api
- NEXT_PUBLIC_MEDIA_URL=http://localhost:5000/media
container_name: audio_archive_frontend
restart: unless-stopped
@R-uan
R-uan / thread_pool.hpp
Created November 13, 2025 00:23
Basic Ahh Thread Pool
class ThreadPool {
public:
inline ThreadPool(size_t n) : stop(false) {
for (size_t i = 0; i < n; i++) {
workers.emplace_back([this]() {
while (true) {
std::function<void()> task;
{
std::unique_lock lock(this->mtx);
this->cv.wait(
@R-uan
R-uan / webp-daemon.rs
Created November 12, 2025 18:45
Daemon to monitor and convert WEBP files to PNG in a chosen folder.
fn ffmpeg_convert(path: &PathBuf) {
if let Some(file_name) = path.file_name().and_then(|n| n.to_str()) {
println!("webp-daemon: new file created: `{file_name}`");
let path_str = path.to_string_lossy();
let mut new_path = PathBuf::from(path);
new_path.set_extension("png");
let new_path_str = new_path.to_string_lossy();
let arguments = ["-i", &path_str, &new_path_str];
if let Ok(status) = Command::new("ffmpeg")
.stderr(Stdio::null())
@R-uan
R-uan / TestWebAppFactory.cs
Last active May 19, 2024 12:25
Custom WebAppFactory for integration/end-to-end tests in ASP.NET Core with a PostgreSQL database
/* Factory receives the Program.cs or the Startup.cs (Program.cs needs to have a class) */
public class TestWebAppFactory : WebApplicationFactory<Program> {
private DatabaseContext? Db_context { set; get; }
protected override void ConfigureWebHost(IWebHostBuilder builder) {
base.ConfigureWebHost(builder);
IConfiguration configuration = new ConfigurationBuilder().AddJsonFile("appsettings.Test.json").Build();
builder.ConfigureTestServices((services) => {
/* Removes any instances of the actual application DatabaseContext*/
@R-uan
R-uan / DatabaseContext.cs
Last active May 19, 2024 12:10
Database context example for a ASP.NET Core application using Entity Framework
public class DatabaseContext : DbContext {
public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options) {}
/* Set the entity Class (Model) */
public DbSet<EntityModel> Entity { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder) {
modelBuilder.Entity<EntityModel>(entity => {
entity.Property(col => col.Column).HasColumnType("/* SQL DATATYPE */");
entity.ToTable("/* Column Name */")
});