This file contains 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
# INSERT fail2ban FORWARD for Docker host | |
sudo iptables -I FORWARD -j f2b-postgres | |
# DELETE fail2ban FORWARD for Docker host | |
sudo iptables -D FORWARD -j f2b-postgres | |
# Save | |
sudo iptables-save |
This file contains 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 | |
SHDIR=$(dirname $0) | |
NOWDA=$(date '+%Y%m%d') | |
NOWDT=$(date '+%Y%m%d%H%M%S') | |
BUDIR="/data/backup/docker/compose/$NOWDA" | |
mkdir -p "$BUDIR" | |
find "$SHDIR" -maxdepth 3 -type d 2>/dev/null | while read COMPOSE_DIR |
This file contains 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
'use client'; | |
import * as React from 'react'; | |
import { | |
AlertDialog, | |
AlertDialogContent, | |
AlertDialogDescription, | |
AlertDialogFooter, | |
AlertDialogHeader, | |
AlertDialogTitle, |
This file contains 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
// app/api/route.ts | |
import { Configuration, OpenAIApi } from 'openai'; | |
export const runtime = 'nodejs'; | |
// This is required to enable streaming | |
export const dynamic = 'force-dynamic'; | |
export async function GET() { | |
const configuration = new Configuration({ | |
apiKey: process.env.OPENAI_API_KEY, |
This file contains 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
const encoder = new TextEncoder(); | |
const ITERATIONS = 65535; | |
const LENGTH = 64; | |
const ALGORITHM = 'PBKDF2'; | |
const DIGEST = 'SHA-256'; | |
const DERIVED_KEY = { | |
name: 'AES-CBC', | |
length: 256, | |
} as const; | |
const USAGES = { |
This file contains 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
import hash from 'object-hash'; | |
export type ObjectCacheFunction<A extends unknown[], V> = (...args: A) => V; | |
const objectMap = cache(() => new Map<string, any[]>()); | |
export const objectCache = <A extends unknown[], V>(fn: ObjectCacheFunction<A, V>): ObjectCacheFunction<A, V> => { | |
const map = objectMap(); | |
return new Proxy( | |
cache((s: string) => fn(...(map.get(s) as A))), | |
{ |
This file contains 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
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment */ | |
'use client'; | |
import type { ElementType, RefCallback } from 'react'; | |
import { createElement, useCallback, useEffect, useMemo, useRef, useState } from 'react'; | |
import { twMerge } from 'tailwind-merge'; | |
import type { PolymorphicComponentProps } from './polymorphic'; | |
export type InViewProps = { | |
/** | |
* The CSS Class that active when inside browser's sight |
This file contains 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
// other allowed node types | |
const allowNodes: number[] = [Node.TEXT_NODE, Node.DOCUMENT_FRAGMENT_NODE] | |
// allowed tags | |
const allowTags = ['div', 'span', 'p', 'img', 'strong', 'i', 'b', 's', 'br', 'a', 'blockquote', 'code', 'del', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'kbd', 'ol', 'ul', 'li', 'sub', 'sup'] | |
// allowed tag's attributes | |
const allowAttrs = ['src', 'width', 'height', 'alt', 'title', 'href', 'style'] | |
// generate almost unique hash that avoid key warning | |
const unsafeHash = () => Math.random().toString(36).substring(2) |
This file contains 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
import { | |
type ComponentProps, | |
createElement, | |
type ElementType, | |
type ForwardedRef, | |
forwardRef, | |
type MutableRefObject, | |
type ReactDOM, | |
type ReactElement, | |
type Ref, |
This file contains 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
<script setup> | |
import useEventBus from './lib/event-bus' | |
const bus = useEventBus() | |
bus | |
.on('session-change', (...args) => { | |
// TODO Session Change | |
console.log('session change event fired', args) | |
}) |
NewerOlder