Skip to content

Instantly share code, notes, and snippets.

View danielres's full-sized avatar

Daniel Reszka danielres

View GitHub Profile
@danielres
danielres / .envrc
Last active March 15, 2024 20:55
Nix flake with node_20 + pnpm
use_flake './flake.nix'
@danielres
danielres / .zshrc
Created March 8, 2024 12:05
Running lvim with its own isolated nodejs using nix-shell
v() {
# runs nvim in a nix-shell with nodejs_20
# sets NPM_GLOBAL_DIR so no sudo is needed to install global npm packages
NODE_STR="nodejs_20"
NPM_GLOBAL_DIR="/home/$USER/.npm-global/$NODE_STR"
mkdir -p $NPM_GLOBAL_DIR
echo "running lvim $1"
echo "within nix-shell -p $NODE_STR"
PATH=$NPM_GLOBAL_DIR/bin:$PATH NPM_CONFIG_PREFIX=$NPM_GLOBAL_DIR nix-shell -p $NODE_STR --run "lvim $1"
}
@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 December 16, 2023 22:23
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