Skip to content

Instantly share code, notes, and snippets.

View danielres's full-sized avatar

Daniel Reszka danielres

  • Pixarea studio
  • Germany
View GitHub Profile
@danielres
danielres / Readme.md
Last active March 8, 2024 12:00
xremap as a service

Place the files

mv config.yml /home/daniel/.config/xremap/config.yml
mv service.sh /home/daniel/.config/xremap/service.sh
sudo mv xremap.service /etc/systemd/system/xremap.service

Start the service

@danielres
danielres / .envrc
Last active March 8, 2024 12:06
nix shell minimal node + pnpm development environment
use nix
@danielres
danielres / flash.js
Last active March 8, 2024 12:07
Svelte flash animation for new elements
// Svelte flash animation for new elements
// source: https://learn.svelte.dev/tutorial/svelte-options
export default function flash(element) {
requestAnimationFrame(() => {
element.style.transition = 'none';
element.style.color = 'rgba(255,62,0,1)';
element.style.backgroundColor = 'rgba(255,62,0,0.2)';
setTimeout(() => {
@danielres
danielres / stateMachine.svelte
Created January 2, 2024 15:15
A basic state machine using only svelte stores
<script lang="ts">
import { derived, readable, writable } from 'svelte/store'
type States = 'view' | 'edit'
const state = writable<States>('view')
const _substate = derived(state, ($state) => {
if ($state === 'edit') return writable<{ item?: number }>({})
return readable(null)
})
@danielres
danielres / Readme.md
Last active November 11, 2024 09:25
Generate pocketbase record options automatically (fields+expand) from zod schemas.
@danielres
danielres / Readme.md
Last active November 22, 2023 15:26
Common ts utils

Common TS utils

A collection of functions in typescript that I use often in different projects.

@danielres
danielres / Readme.md
Last active November 22, 2023 13:03
Sveltekit + Pocketbase SSR

Sveltekit + Pocketbase SSR

The minimal steps to integrate Pocketbase with Sveltekit SSR. Not striclty needed as Pocketbase can be used from the browser only. But useful in certain cases.

@danielres
danielres / configuration.nix
Created October 10, 2023 10:53
My Nixos configuration experiments under qemu
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
@danielres
danielres / signals.ts
Last active October 5, 2023 10:34
A minimal signals implementation in typescript. This is a toy example to help me wrap my head around the pattern.
export type Signal<T> = ReturnType<typeof createSignal<T>>
export function createSignal<Value>(initialValue: Value): {
subscribe: (listener: (v: Value) => void) => () => void
val: Value
} {
let value = initialValue
const listeners: ((v: Value) => void)[] = []
function subscribe(listener: (v: Value) => void) {
@danielres
danielres / Ratio.svelte
Last active September 25, 2023 09:22
Svelte component to fill all available space while maintaining aspect ratio.
<!--
@component
Allows to create responsive containers with a fixed aspect ratio.
Uses container queries to determine the size of the container.
The contained element will be as large as possible while maintaining the aspect ratio.
@example
```tsx
<div class="outer h-[100svh] grid grid-rows-[auto_1fr_auto]">