This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| MYSQL_USER=root | |
| MYSQL_PASS=root | |
| MYSQL_DB=test | |
| BACKUP_DIR=/var/local/backup | |
| LOGS_DIR=/var/log | |
| # Equals to 3 last days |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| USER=root | |
| PASSWORD=root | |
| DATE_NOW="`date '+%Y-%m-%d_%H-%M-%S'`" | |
| DIR=/var/local/backup | |
| DATABASES=`mysql -u$USER -p$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database` | |
| echo "Databases found: $DATABASES" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface RGBAtoRGBOptions { | |
| toColorRGBA: string; | |
| backgroundColorRGB?: string; | |
| } | |
| function rgbaToRgb({ toColorRGBA, backgroundColorRGB = 'rgb(255,255,255)' }: RGBAtoRGBOptions) { | |
| const [r, g, b, a] = toColorRGBA | |
| .replace(/rgba|\(|\)/g, '') | |
| .split(',') | |
| .map((str) => parseInt(str, 2)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # .githooks/commit-msg | |
| # Strip Cursor-injected footer from commit messages | |
| msg="$1" | |
| [ -z "$msg" ] || [ ! -f "$msg" ] && exit 0 | |
| tmp="${msg}.tmp" | |
| sed '/Made-with: Cursor/d' "$msg" > "$tmp" && mv "$tmp" "$msg" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1) Open TortoiseGit -> Settings -> Network | |
| 2) SSH Client -> change to "C:\Program Files\Git\usr\bin\ssh.exe" instead of "TortoiseGitPlink.exe" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Tracks which heading (by id) is most visible in the viewport via IntersectionObserver. | |
| import { useEffect, useRef, useState } from 'react'; | |
| interface UseIntersectionOptions { | |
| root?: HTMLElement | null; | |
| rootMargin?: string; | |
| threshold?: number | number[]; | |
| } | |
| export const useActiveAnchor = (ids: string[], options: UseIntersectionOptions = {}) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Calls the given handler when the user presses Escape (keydown on document.body). Handy for closing modals, menus, and overlays. | |
| import { useEffect } from 'react'; | |
| export const useCallbackOnEscape = (handleClose?: () => void) => { | |
| useEffect(() => { | |
| if (typeof handleClose === 'function') { | |
| const closeOnEscapeKey = (e: KeyboardEvent) => (e.key === 'Escape' ? handleClose() : null); | |
| document.body.addEventListener('keydown', closeOnEscapeKey); | |
| return () => { | |
| document.body.removeEventListener('keydown', closeOnEscapeKey); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // On copy, rewrites clipboard text to append a random copyright line from the list (skips URLs, IP:port, and selections inside code/inputs). | |
| import React from 'react'; | |
| import sample from 'lodash/sample'; | |
| const IP_ADDR_PORT_REGEX = /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5})$/; | |
| const URL_REGEX = | |
| /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g; | |
| const isURL = (str: string) => URL_REGEX.test(str); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // On non-touch devices, adds a custom dual-layer cursor (ring + lagging dot with difference blend) | |
| // that grows over links, buttons, and form controls. | |
| import React from 'react'; | |
| export function useCursorEffect() { | |
| React.useEffect(() => { | |
| const isMobileDevice = () => { | |
| return ( | |
| window.matchMedia('(pointer: coarse)').matches || /Mobi|Android/i.test(navigator.userAgent) | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Builds Theme UI `sx` transforms so a sticky/floating bar slides in on scroll-up or near the top | |
| // and slides away on scroll-down; optional burger-menu attrs keep it visible while the menu is open. | |
| import React from 'react'; | |
| import { BoxProps } from 'theme-ui'; | |
| import { useScrollDirection, ScrollDirection } from '@/hooks/useScrollDirection'; | |
| const SCROLL_Y_OFFSET_PX = 500; | |
| interface DirectionTransformProps { |
OlderNewer