Skip to content

Instantly share code, notes, and snippets.

View joeywang's full-sized avatar

Joey Wang joeywang

  • reallyenglish.com
  • London
View GitHub Profile

Passing Sass Variables When Building Web Apps

In our project, scrom-wrapper is using the training-components library. We want to implement a flexible theming system by changing the primary color in training-components. This article explains how we can set environment variables during the build process of scorm-wrapper to customize the primary color of the imported training-components.

Why We Want to Pass Variables When Building

Passing Sass variables during the build process offers several advantages:

  1. Flexibility: It allows us to change the theme without modifying the source code.
  2. Reusability: The same components can be used with different themes in various projects.

Devise Metaprogramming: A Deep Dive into current_user

1. What is Devise?

Devise is a flexible authentication solution for Rails based on Warden. It's a full-featured authentication framework that handles everything from encrypting passwords to creating and managing user sessions. Devise is highly modular and configurable, making it a popular choice for Rails developers.

2. Metaprogramming in Devise

Metaprogramming is the writing of computer programs that write or manipulate other programs (or themselves) as their data. In Ruby, this often involves dynamically defining methods, classes, or modules.

@joeywang
joeywang / multiple-command-in-container.md
Created October 20, 2024 23:11
Running Multiple Commands Simultaneously in a Container: A Comprehensive Guide

Running Multiple Commands Simultaneously in a Container: A Comprehensive Guide

Introduction

When working with containers, you may often need to run multiple processes or commands concurrently. This need becomes particularly apparent in development scenarios, such as debugging a Rails application in Visual Studio Code while simultaneously running the Rails server. In this article, we'll explore various methods to achieve this, focusing on the specific use case of running rdbg listen with a server and the Rails server simultaneously.

1. GNU Parallel

GNU Parallel is a shell tool for executing jobs in parallel. It can be used to run multiple commands simultaneously within a container.

How to Debug Docker Image Builds

This guide covers various techniques to debug Docker image builds, from basic to advanced approaches.

Common Debugging Scenarios

1. Using BuildKit's Enhanced Debugging Features

BuildKit (the default builder in modern Docker) offers several powerful debugging options:

@joeywang
joeywang / buildx-debug.md
Created October 24, 2024 21:06
Advanced Docker Buildx Debugging Guide: Using --on-error

Advanced Docker Buildx Debugging Guide: Using --on-error

Introduction to Buildx --on-error

The --on-error flag in Docker Buildx is a powerful debugging feature that allows you to inspect the build container's state when a build step fails. This is particularly useful for:

  • Investigating build failures in complex Dockerfiles
  • Debugging package installation issues
  • Troubleshooting configuration problems
  • Examining file system state at the point of failure
Redis::CommandError in PlanningHub::AthleteEventsController#update_attributes

MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.
Extracted source (around line #246):

# Fix
config set stop-writes-on-bgsave-error no
# talk to docker through unix-socket
curl --unix-socket /var/run/docker.sock 'http://localhost/images/json?all=true' | jq '.'

how to rsync file

# make sure rsync installed on container first
rsync --include='lib' --include='lib/**' --exclude='*' -e 'docker exec -i' -avz . mycontainer:/app/
  1. flatten the commits in main/master

  2. rebase feature branches

  3. squash into one commit

git merge --squash branch_name

For PostgreSQL, I'm using pgpool + postgres operator. So pgpool as the load balancer and read/write splitter. postgres operator is managing the primary/replica and fail over. I'm having some problems with read/write splitting and I have to set up a rule at pgpool to split the SQLs. It's interesting but a lot of problems. The challenge is to keep the balance between in-time-copy and obsolete readings.

:echo fnamemodify(expand("%"), ":~:.")

:echo expand("%:~:.")

linenumber