Skip to content

Instantly share code, notes, and snippets.

@nberlette
nberlette / list-all.ts
Last active April 18, 2024 18:43
Deno KV: list / search / sort huge batches of entries in database
export interface ListAllOptions<T> extends Deno.KvListOptions {
comparer?(a: Deno.KvEntry<T>, b: Deno.KvEntry<T>): number;
}
export interface ListEntry<T> extends Deno.KvEntry<T> {
readonly cursor: string;
}
export async function listAll<T>(
kv: Deno.Kv,
@acheong08
acheong08 / htmj.js
Created November 5, 2023 17:21
HTMX but with JSON
class HTMJ {
constructor() {
this.init();
}
init() {
document.addEventListener("DOMContentLoaded", () => {
this.parseTemplates();
});
}
@b01
b01 / download-vs-code-server.sh
Last active June 6, 2024 13:15
Linux script to download latest VS Code Server, good for Docker (tested in Alpine).
#!/bin/sh
# Copyright 2023 Khalifah K. Shabazz
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the “Software”),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
@jmrobles
jmrobles / rancher-container.sh
Last active June 4, 2020 17:36
Rancher install
docker run -d --restart=unless-stopped \
-p 80:80 -p 443:443 \
-v /root/rancher:/var/lib/rancher \
--name rancher-server \
rancher/rancher:latest \
--acme-domain <YOUR-DOMAIN-FOR-RANCHER-SERVER>
@nuxodin
nuxodin / Event.submitter.polyfill.js
Created April 8, 2020 21:32
Event.submitter polyfill
!function(){
var lastBtn = null
document.addEventListener('click',function(e){
if (!e.target.closest) return;
lastBtn = e.target.closest('button, input[type=submit]');
}, true);
document.addEventListener('submit',function(e){
if (e.submitter) return;
var canditates = [document.activeElement, lastBtn];
for (var i=0; i < canditates.length; i++) {
@peterreisz
peterreisz / index.js
Last active May 30, 2024 10:00
Dev server proxy for stencil. Backend is running on port 3000, stencil on 3333, open port 5000 for development. Only `/api` requests are sent to the backend, everything else served by stencil.
const http = require('http');
const httpProxy = require('http-proxy');
const proxyApi = new httpProxy.createProxyServer({
target: {
host: '127.0.0.1',
port: 3000
}
});
proxyApi.on('error', () => {});
@l1x
l1x / convert_json_to_yaml.py
Last active August 24, 2022 21:53
Python 3 version of converting JSON to YAML one liner
python -c 'import sys, yaml, json; j=json.loads(sys.stdin.read()); print(yaml.safe_dump(j))'
# on windows(PS):
# Get-Content example.json | python -c 'import sys, yaml, json; j=json.loads(sys.stdin.read()); print(yaml.safe_dump(j))' > example.yaml
# on Unix clones
# python -c 'import sys, yaml, json; j=json.loads(sys.stdin.read()); print(yaml.safe_dump(j)) < example.json > example.yaml
#!/bin/bash
DIR="$HOME/bin"
cd /tmp
curl -s https://api.github.com/repos/cdr/code-server/releases/latest \
| grep "browser_download_url.\+linux-x86_64.tar.gz" \
| cut -d : -f 2,3 \
| tr -d \" \
@abhinavdhasmana
abhinavdhasmana / config.yaml
Created July 5, 2019 04:35
config file for verdaccio with htpasswd and no user creation
#
# This is the config file used for the docker images.
# It allows all users to do anything, so don't use it on production systems.
#
# Do not configure host and port under `listen` in this file
# as it will be ignored when using docker.
# see https://github.com/verdaccio/verdaccio/blob/master/wiki/docker.md#docker-and-custom-port-configuration
#
# Look here for more config file examples:
# https://github.com/verdaccio/verdaccio/tree/master/conf
asn() {
if [ -z "$1" ]
then
echo "usage: asn url" 1>&2
return 1
fi
ips=$(dig $DIG_ARGS +short $1)
if [ -z "$ips" ]
then