Skip to content

Instantly share code, notes, and snippets.

View danielres's full-sized avatar

Daniel Reszka danielres

View GitHub Profile
@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]">
@danielres
danielres / .eslintignore
Last active June 8, 2020 06:53
nextjs typescript config
node_modules
dist
coverage
.eslintrc.js
@danielres
danielres / apollo-server-express-middlewares-example.js
Last active May 26, 2020 09:05
using express js middlewares in apollo server graphql context
import { ApolloServer, gql } from "apollo-server-micro"
import cookieSession from "cookie-session"
const ONE_HOUR = 60 * 60 * 1000
const typeDefs = gql`
type Query {
hello: String!
}
`
@danielres
danielres / keybase.md
Created January 25, 2020 11:45
keybase.md

Keybase proof

I hereby claim:

  • I am danielres on github.
  • I am danielres (https://keybase.io/danielres) on keybase.
  • I have a public key ASA7WN7ywCsV8R3AKSdH014O0nX8-sWUv4VlO2YxGMWZMwo

To claim this, I am signing this object:

#!/bin/bash
# Finds a process by regexp then terminates
# it, including all subprocesses
# usage: ./terminate <PROCESS_NAME_OR_PATTERN>
kill -TERM -- -$(pgrep -f "$1")
@danielres
danielres / defaultPropsExample.tsx
Last active October 22, 2019 14:11
React + typescript + defaultProps example
// Adapted from: https://github.com/microsoft/TypeScript/issues/27425
// This workaround should become deprecated by: https://github.com/microsoft/TypeScript/pull/29818
import * as React from "react";
Person.defaultProps = { telephone: "222-333-4444" };
function Person({ name, telephone }: { name: string; telephone: string }) {
return (
<div>
@danielres
danielres / curl_wait_for_url.sh
Last active October 11, 2019 12:18
wait for url example
sleep 10
curl --retry 8 --retry-connrefused -v localhost:1234