Skip to content

Instantly share code, notes, and snippets.

Avatar
🤓
deploying awesomeness

Jaka Hudoklin offlinehacker

🤓
deploying awesomeness
View GitHub Profile
@offlinehacker
offlinehacker / rxdb-external-attachments-storage.ts
Created Jul 11, 2022
RxDB plugin to allow storage of attachments in external storage
View rxdb-external-attachments-storage.ts
import {
BulkWriteRow,
EventBulk,
RxAttachmentData,
RxAttachmentWriteData,
RxDocumentData,
RxDocumentDataById,
RxJsonSchema,
RxStorage,
RxStorageBulkWriteResponse,
@offlinehacker
offlinehacker / dom.ts
Last active Mar 9, 2022
DOM functions
View dom.ts
export const getScrollParent = (node?: Element | null): Element | null => {
if (node == null) {
return null;
}
if (node.scrollHeight > node.clientHeight) {
return node;
} else {
return getScrollParent(asElement(node.parentNode));
}
@offlinehacker
offlinehacker / multipass-docker.yml
Created Mar 2, 2022
Multipass cloud config to create VM with docker installed
View multipass-docker.yml
#cloud-config
groups:
- docker
users:
- name: ubuntu
sudo: ALL=(ALL) NOPASSWD:ALL
groups: users,docker,admin
ssh-authorized-keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDwB83EYt+55hfu6SzIFKrZ7E8Vli2NaZ5E1vgieFslSGJfJGECfrK8m26/5US/W+Rjfgi9VR0L1zY92eld92134mQQFiPeGWpU88iUVykNmm6B8iA6I/AlzPa+qeZaH5iteWvUxqApZ1s0nFnIVA9PI9+OSzEX/nDrWEiNMxc2H1L0GIf/OAzCEs8WllVSHSqA35wuXQBkPDF6d+SMtRe6tZ82BT5InSFmWVP+TBREV2/okrgEJSF9exD8myXKuPqe4pCZqVgiHMi1NpGs/sDack/yuOHVT+eMKVE23j4r5zhvkMS4Y4oEpj4v0V8DChZSniMvhvp9qxKMJJKwKDWn
@offlinehacker
offlinehacker / devcontainer.sh
Created Dec 1, 2021
Devcontainer env probe
View devcontainer.sh
#!/bin/bash
[[ $ENVRC_RUN != yes ]] && source /etc/envrc
# whether running via vscode env probe
if shopt -q login_shell && [[ "$BASH_EXECUTION_STRING" =~ $HOME/.vscode-server/bin/.*/node ]]; then
old_bash_path="$(which bash)"
if [ ! -z "${ENV_PRINT_COMMAND}" ]; then
cd "${WORKSPACE_DIR}"
@offlinehacker
offlinehacker / subscribe-erc20-transfers.mjs
Last active Nov 23, 2021
Subscribe to ERC20 Transfer events
View subscribe-erc20-transfers.mjs
import { Contract, getDefaultProvider, utils } from "ethers";
const provider = getDefaultProvider("homestead");
const abi = [
"function symbol() view returns (string)",
"function decimals() view returns (uint8)",
"event Transfer(address indexed from, address indexed to, uint value)",
];
@offlinehacker
offlinehacker / Dockerfile
Created Mar 8, 2021
k3s dind rootless devcontainer
View Dockerfile
FROM xtruder/debian-nix-devcontainer:flakes
# docker user
ARG DOCKER_GID=966
RUN groupadd -g ${DOCKER_GID} docker && usermod -a -G docker ${USERNAME}
# create volume for pulumi
RUN sudo -u user mkdir -p /home/${USERNAME}/.pulumi
VOLUME /home/${USERNAME}/.pulumi
@offlinehacker
offlinehacker / Dockerfile
Last active Aug 20, 2021
dind k3s devcontainers root
View Dockerfile
FROM xtruder/debian-nix-devcontainer:flakes
# docker user
ARG DOCKER_GID=966
RUN groupadd -g ${DOCKER_GID} docker && usermod -a -G docker ${USERNAME}
# create volume for pulumi
RUN sudo -u user mkdir -p /home/${USERNAME}/.pulumi
VOLUME /home/${USERNAME}/.pulumi
@offlinehacker
offlinehacker / olm.ts
Last active Aug 20, 2021
Operator lifecycle manager deployed with pulumi
View olm.ts
import * as path from 'path';
import * as pulumi from '@pulumi/pulumi';
import * as k8s from '@pulumi/kubernetes';
import { filesDir } from './util';
interface OperatorLifecycleManagerArgs {
namespace?: pulumi.Input<string>;
imageRef?: pulumi.Input<string>;
@offlinehacker
offlinehacker / csv2pocket.py
Created Oct 16, 2020
csv2pocket - tool to import csv to pocket
View csv2pocket.py
import csv
import argparse
import sys
import requests
parser = argparse.ArgumentParser()
parser.add_argument("--csv", help="CSV to import", required=True)
parser.add_argument("--encoding", help="File encoding", default="utf-8")
parser.add_argument("--token", help="API token to use", required=True)
parser.add_argument("--consumerkey", help="Consumer key token to use", required=True)