Skip to content

Instantly share code, notes, and snippets.

View genaroibc's full-sized avatar

Genaro Bonavita genaroibc

View GitHub Profile
@genaroibc
genaroibc / getHexColorWithOpacity.js
Created April 16, 2024 12:32
JS function to get hexadecimal color with opacity based on the given color and opacity percentage
/**
* Returns a hexadecimal color with opacity based on the given color and opacity percentage.
*
* @example getHexColorFromOpacityPercentage('#FF0000', 0.5) // '#FF000080'
*
* @param {string} color - The base color in hexadecimal format.
* @param {number} opacity - The opacity percentage (0-1).
* @returns {string} The hexadecimal color with opacity.
*/
function getHexColorFromOpacityPercentage(color, opacity) {
@pingrishabh
pingrishabh / useOptimisticUpdate.js
Created September 24, 2023 08:36
Simple hook to perform optimistic updates with react-query
import { useCallback } from "react";
import { useQueryClient } from "@tanstack/react-query";
export default function useOptimisticUpdate() {
const queryClient = useQueryClient();
return useCallback(
async (queryKey, updater) => {
await queryClient.cancelQueries({ queryKey });
@LeviSnoot
LeviSnoot / discord-timestamps.md
Last active October 24, 2025 08:27
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
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active October 29, 2025 05:20
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example