Skip to content

Instantly share code, notes, and snippets.

View maietta's full-sized avatar

Nick Maietta maietta

View GitHub Profile
@maietta
maietta / +page.svelte
Created November 18, 2024 03:38
Example Svelte 5 Real Estate Form
<script lang="ts">
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { onMount } from 'svelte';
import { queryParameters, ssp } from 'sveltekit-search-params';
import Pagination from './pagination.svelte';
let { records, ...props } = $props();
const system = $state({ Class: '', Type: '', page: 1 });
@maietta
maietta / SecretFormula.ts
Created November 16, 2024 21:10
The secret formula search form.
<script lang="ts">
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { onMount } from 'svelte';
import { queryParameters } from 'sveltekit-search-params';
// Initialize query parameters management
const params = queryParameters(
{
test: {
@maietta
maietta / RETSMetadataTable.d.ts
Last active November 12, 2024 04:02
generateCreateTableSql function
// Define the type for individual fields
export interface RETSField {
SystemName?: string | string[];
Interpretation?: string[];
DataType?: string[];
MaximumLength?: number[];
Precision?: number[];
LongName?: string[];
}
@maietta
maietta / watch.ts
Last active November 3, 2024 01:54
Watch for events on Pocketbase
import PocketBase from "pocketbase";
import eventsource from "eventsource";
global.EventSource = eventsource as unknown as typeof EventSource;
const pb = new PocketBase(process.env.POCKETBASE_URL);
// Store the initial states of all records in a cache
const previousRecords: { [recordId: string]: any } = {};
async function watchCollectionChanges(collection: string) {
@maietta
maietta / Dockerfile
Last active September 18, 2024 16:45
Run SvelteKit with Bun
ARG BUN_VERSION=1.1.27
FROM oven/bun:${BUN_VERSION} AS builder
# Install required dependencies
RUN apt-get update && \
apt-get install -y \
curl \
xz-utils \
&& rm -rf /var/lib/apt/lists/*
@maietta
maietta / +page.svelte
Created July 31, 2024 23:53
Proxy SSE data streams in SvelteKit
<script lang="ts">
import { onMount } from 'svelte';
import { writable } from 'svelte/store';
// Define the type for your message objects
interface Message {
now: number;
created_at: string;
// Add any other properties your message might have
}
@maietta
maietta / demo.svelte
Last active July 7, 2024 22:17
Fancy Hero Horizontal Accordion, no JS and no anchor tags
<script lang="ts">
let sections = [
{
title: 'WEBSITES',
content: 'Content for section 1',
color: 'bg-[#85aa74]'
},
{
title: 'WEB HOSTING',
color: 'bg-[#fee6a6]',
@maietta
maietta / patch-bits-ui-link-preview-trigger.js
Created July 4, 2024 21:51
Add as a postinall for package upgrades to fix "hydration mismatch" error.
@maietta
maietta / getDNS.sh
Created February 29, 2024 21:23
Coolify - Pull IP's and their associated domains.
#!/bin/bash
docker exec -i coolify-db psql -U coolify -t -c "\
SELECT
json_agg(json_build_object(
'uuid', uuid,
'destination_id', destination_id,
'name', name,
'domain', domain,
'ip', ip,
@maietta
maietta / command.txt
Created February 29, 2024 20:28
Coolify DNS entries lookup
docker exec -i coolify-db psql -U coolify -t -c "\
SELECT
json_agg(json_build_object(
'uuid', uuid,
'destination_id', destination_id,
'name', name,
'domain', domain,
'ip', ip,
'source_table', source_table,
'docker_compose', docker_compose