Skip to content

Instantly share code, notes, and snippets.

View Maxiviper117's full-sized avatar
🎯
Focusing

David Maxiviper117

🎯
Focusing
View GitHub Profile
@Maxiviper117
Maxiviper117 / Dockerfile
Created April 9, 2023 09:42
Example `dockerfile` for a Sveltekit Project
# ---- Base Node ----
FROM node:19-alpine AS base
WORKDIR /app
COPY package*.json ./
# ---- Dependencies ----
FROM base AS dependencies
RUN npm ci
# ---- Build ----
@Maxiviper117
Maxiviper117 / .prettierrc
Created April 10, 2023 08:59
Prettier config for Sveltekit project
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }],
"svelteAllowShorthand": false,
"svelteSortOrder": "scripts-options-markup-styles",
@Maxiviper117
Maxiviper117 / main.py
Created February 2, 2024 08:25
Delete all node_modules in a specified directory using Python
from pathlib import Path
import shutil
def delete_node_modules(directory):
deleted_any = False # Track if any node_modules directories have been deleted
for path in directory.rglob('*'): # Use rglob to find all paths
if path.name == 'node_modules' and path.is_dir():
shutil.rmtree(path)
print(f"Deleted {path}")
deleted_any = True
@Maxiviper117
Maxiviper117 / color-shades-generator.scss
Last active March 14, 2024 16:01
SCSS Color Shades Generator: Dynamic CSS Variable Creation for Theming
// Import the Sass math module for division and other mathematical operations
@use "sass:math";
// Function to generate a series of color shades from a base color
@function generate-shades($base-color) {
// Initialize an empty map to store the shades
$shades: ();
// Define the scale for the shades
$scale: (50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950);
@Maxiviper117
Maxiviper117 / README.md
Created July 19, 2024 07:43
A Python script to batch convert pure black pixels to transparent in images and save them as PNGs with an alpha channel.

Sure, here's the content for a GitHub Gist including a description on how to use the script.

Gist Description

This script processes a batch of images, converting all pure black background pixels to transparent, and saves the images as PNG files with an alpha channel. It's useful for preparing images with transparent backgrounds for various applications.

Gist Content

batch_image_transparency.py

import os
@Maxiviper117
Maxiviper117 / create_fastapi_directories.ps1
Last active August 5, 2024 17:39
PowerShell script to create directory structure for a FastAPI project
# Define the base directory as the app folder inside the current directory
$baseDir = Join-Path -Path (Get-Location) -ChildPath "app"
# Define the folder structure within the app directory
$folders = @(
"$baseDir/models",
"$baseDir/schemas",
"$baseDir/crud",
"$baseDir/routers",
"$baseDir/db",
@Maxiviper117
Maxiviper117 / docker-compose.yml
Created August 27, 2024 16:00
Docker Compose Setup for PostgreSQL with PgBouncer and Adminer
# Docker Compose file for setting up PostgreSQL with PgBouncer and Adminer
version: '3.8' # Specify the Docker Compose version
services:
# PostgreSQL database service
postgredb:
image: postgres:latest # Use the latest PostgreSQL image
environment:
# Environment variables are loaded from the .env file
@Maxiviper117
Maxiviper117 / smooth-scrolling.js
Created September 7, 2024 11:03
Smooth Scrolling JS for Any Page
document.addEventListener("DOMContentLoaded", function () {
const body = document.body;
const html = document.documentElement;
let sx = 0, sy = 0; // For scroll positions
let dx = sx, dy = sy; // For container positions
let scrollSpeed = 40; // Adjust scroll speed based on mouse wheel movement
// Set the body's height to be the height of the scrollable content
const pageHeight = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
@Maxiviper117
Maxiviper117 / ScrollTransform.js
Created September 7, 2024 20:38
A reusable JavaScript class to apply dynamic CSS transformations (scale, rotate, translate) to elements based on vertical scroll position
/**
* ScrollTransform Class (Extended Version)
* A reusable JavaScript class to apply dynamic CSS transformations (scale, rotate, translate, opacity)
* to elements based on the vertical scroll position with various options.
*
* Usage Example:
* const scrollEffect = new ScrollTransform('.my-element', {
* scale: true, rotate: true, translateY: true, opacity: true, startPosition: 100, endPosition: 1000
* });
*
@Maxiviper117
Maxiviper117 / regex-replace.md
Created October 5, 2024 20:00
Replacing Localization Strings in Laravel in Vscode

Replacing Localization Strings in Laravel

This guide helps you replace all localization strings in the form of {{ __('...') }} with the plain text inside the __('...') function in Laravel projects.

Regular Expression for Search

  1. Pattern: Use this regular expression to match the {{ __('...') }} structure:

{{\s*__(\s*'"['"]\s*)\s*}}