Skip to content

Instantly share code, notes, and snippets.

@ribonuclecode
ribonuclecode / tailwindDynamicClassesFromReactProps.md
Created August 2, 2024 06:03
Solving Dynamic Class Generation with Tailwind CSS in React

The Challenge

Tailwind CSS, while powerful, faces limitations when it comes to generating dynamic classes. This restriction poses a significant challenge for React developers who aim to define component styles through props. The core issue lies in Tailwind's inability to dynamically alter classes due to its underlying architecture.

Prerequisites

  • Tailwind CSS version 3.44 or higher

The Solution: CSS Variables

@ribonuclecode
ribonuclecode / search_texts.py
Created June 7, 2024 10:06
Python script to search for specified text patterns files within a selected directory, ignoring specified subdirectories. Generates a report with the count and percentage of occurrences of each pattern.
import os
import re
import tkinter as tk
from tkinter import filedialog
#################
# Instructions  #
#################
@ribonuclecode
ribonuclecode / branch-fu.md
Created September 16, 2022 07:44 — forked from unbracketed/branch-fu.md
Moving commits between branches

Example: Moving up to a few commits to another branch

Branch A has commits (X,Y) that also need to be in Branch B. The cherry-pick operations should be done in the same chronological order that the commits appear in Branch A.

cherry-pick does support a range of commits, but if you have merge commits in that range, it gets really complicated

git checkout branch-B
git cherry-pick X
git cherry-pick Y
@ribonuclecode
ribonuclecode / debounce-lodash.js
Created September 21, 2021 16:16 — forked from Yawenina/debounce-lodash.js
lodash debounce and throttle source code
const nativeMax = Math.max;
const nativeMin = Math.min;
function debounce(func, wait, options) {
let lastArgs,
lastThis,
maxWait,
result,
timerId,
lastCallTime,
lastInvokeTime = 0,
@ribonuclecode
ribonuclecode / emotion-guidelines.md
Created August 20, 2021 02:03 — forked from alexilyaev/emotion-guidelines.md
CSS in JS - Emotion Guidelines

CSS-in-JS

This repo uses a CSS-in-JS library called Emotion for its styling.

Why Emotion?

Emotion is a performant and flexible CSS-in-JS library. Building on many other CSS-in-JS libraries, it allows us to style apps quickly with string or object styles. It has predictable composition to avoid specificity issues in CSS. With source maps and labels, Emotion has a great developer experience and performance with heavy caching in production.

Also, Material UI v5 will most likely use Emotion instead of JSS:
material-ui - [RFC] v5 styling solution

@ribonuclecode
ribonuclecode / foo.md
Created August 20, 2021 02:00 — forked from OliverJAsh/foo.md
Avoiding CSS overrides in responsive components

Avoiding CSS overrides in responsive components

I would like to demonstrate some of the benefits of scoped styles over mobile-first CSS with overrides for wider breakpoints. I'll start by explaining the two approaches, before listing the benefits.

Mobile-first with overrides for wider breakpoints

h2 {
  color: black;
 font-size: 2em;
@ribonuclecode
ribonuclecode / git-aliases.md
Created August 11, 2021 16:51 — forked from mwhite/git-aliases.md
The Ultimate Git Alias Setup

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc
@ribonuclecode
ribonuclecode / cmd.py
Created April 6, 2019 16:35 — forked from dhrrgn/cmd.py
Running a command in Python and optionally processing the output in realtime.
import shlex
import subprocess
import sys
def run_cmd(cmd, callback=None, watch=False):
"""Runs the given command and gathers the output.
If a callback is provided, then the output is sent to it, otherwise it
is just returned.
@ribonuclecode
ribonuclecode / publickey-git-error.markdown
Created March 9, 2019 02:24 — forked from adamjohnson/publickey-git-error.markdown
Fix "Permission denied (publickey)" error when pushing with Git

"Help, I keep getting a 'Permission Denied (publickey)' error when I push!"

This means, on your local machine, you haven't made any SSH keys. Not to worry. Here's how to fix:

  1. Open git bash (Use the Windows search. To find it, type "git bash") or the Mac Terminal. Pro Tip: You can use any *nix based command prompt (but not the default Windows Command Prompt!)
  2. Type cd ~/.ssh. This will take you to the root directory for Git (Likely C:\Users\[YOUR-USER-NAME]\.ssh\ on Windows)
  3. Within the .ssh folder, there should be these two files: id_rsa and id_rsa.pub. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type ls to see a directory listing. If those two files don't show up, proceed to the next step. NOTE: Your SSH keys must be named id_rsa and id_rsa.pub in order for Git, GitHub, and BitBucket to recognize them by default.
  4. To create the SSH keys, type ssh-keygen -t rsa -C "your_email@example.com". Th
@ribonuclecode
ribonuclecode / scriptsmethods.json
Last active December 21, 2016 02:52
JSON Methods
{
"Group": {
"CreateGroup": {
"param": "()",
"description": "N/A",
"return": "Group"
},
"SelectWithSumEqual": {
"param": "(Group g, int player, function f, int sum, int min, int max, ...)",
"description": "N/A",