Skip to content

Instantly share code, notes, and snippets.

View lightningspirit's full-sized avatar
🏠
Working from home

Vitor Carvalho lightningspirit

🏠
Working from home
View GitHub Profile
@lightningspirit
lightningspirit / LICENSE
Last active November 4, 2025 10:25
Strict ISO 8601 Date Regex + Test Suite
Copyright 2025 lightningspirit@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
@lightningspirit
lightningspirit / package.json
Created September 11, 2025 13:19
TypeScript String Utils
{
"name": "@lightningspirit/string-utils",
"license": "MIT",
"type": "module",
"exports": {
".": {
"types": "./dist/string-utils.d.ts",
"tsx": "./src/string-utils.ts",
"import": "./dist/string-utils.mjs",
"require": "./dist/string-utils.js"
@lightningspirit
lightningspirit / doing-it-wrong-filter.php
Created November 21, 2024 22:13
Remove notice messages for _load_textdomain_just_in_time being loaded before init, in WordPress 6.7
<?php
/**
* Plugin Name: Shut I18n Doing It Wrong Messages
* Description: Filters _load_textdomain_just_in_time doing it wrong messages in 6.7
* Author: Move Your Digital, Inc.
* Author URI: https://moveyourdigital.com
* Version: 0.0.1
*
* @package SIDIWM
*/
@lightningspirit
lightningspirit / pocketbase-js-sdk.types.d.ts
Created June 30, 2024 11:52
Testing PocketBase typing system in JS SDK
import PocketBase, {
BaseAuthStore,
ListResult,
LogService,
RecordFullListOptions,
RecordListOptions,
RecordModel,
RecordOptions,
RecordService,
} from 'pocketbase'
@lightningspirit
lightningspirit / client.ts
Created June 25, 2024 10:33
Pocketbase typings for collections
import PocketBaseClient from './pocketbase.ts'
type RecordMap = {
accounts: RecordAccount
categories: RecordCategory
pages: RecordPage
prices: RecordPrice
products: RecordProduct
users: RecordUser
}
@lightningspirit
lightningspirit / date.ml
Created May 8, 2024 21:26
[WIP] OCaml Date implementation
open Unix
type date = {
year : int;
month : int;
day : int;
}
exception InvalidDate of string
@lightningspirit
lightningspirit / react-immutable-data-structures-hooks.md
Last active August 8, 2024 15:23
React Immutable Data Structures Hooks

React Immutable Data Structures Hooks

Popular data structures implemented in immutable React hooks.

Hooks:

  • useArray
  • useHeap
  • useList
  • useQueue
  • useStack
@lightningspirit
lightningspirit / docker-remote-plugin.md
Last active August 8, 2024 15:26
Docker Client Plugin to SSH Remote Docker Hosts

Docker Client Plugin to SSH Remote Docker Hosts

Configuration for each project using a simple YAML file. The docker remote command reads the relative local file docker-remote.yml to access docker hosts. Uses SSH under the hood.

Examples of usage

Showing remote running containers

Implicit user parameter

docker remote remote-hostname ps

function useFileUpload() {
const [total, setTotal] = useState(0)
const [file, setFile] = useState<File>()
const [paused, setPaused] = useState(false)
const [uploaded, setUploaded] = useState(0)
const pause = () => setPaused(true)
const resume = () => setPaused(false)
function upload(file: File) {
@lightningspirit
lightningspirit / create-i18n-context.ts
Last active February 6, 2024 17:07
React I18n only server side
import 'server-only'
import serverOnlyContext from './server-only-context'
export type Locale = string
export const I18nContext = serverOnlyContext<Locale>('en')