Skip to content

Instantly share code, notes, and snippets.

View offlinehacker's full-sized avatar
🤓
deploying awesomeness

Jaka Hudoklin offlinehacker

🤓
deploying awesomeness
View GitHub Profile
@offlinehacker
offlinehacker / main.go
Created August 13, 2024 12:19
Example of otel golang metrics
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"os"
"sync"
"time"
@offlinehacker
offlinehacker / k3s-nodeip-tailscale.service.j2
Created June 1, 2024 12:02
Systemd service for k3s to take tailscale IP as node ip
[Unit]
Description=Generates K3S NodeIP Entry With Tailscale IP
Requires=network.target
Requires=tailscaled.service
Before=k3s.service
[Service]
Type=oneshot
RemainAfterExit=yes
@offlinehacker
offlinehacker / fetch_protovpn.yml
Created June 1, 2024 11:46
Ansible fetch protovpn servers (I don't use anymore)
---
- hosts: localhost
tasks:
- name: get protonvpn servers
ansible.builtin.uri:
url: https://api.protonmail.ch/vpn/logicals
register: protonvpn_servers
- name: filter protonvpn profiles
set_fact:
@offlinehacker
offlinehacker / ubuntu-dev
Created September 8, 2023 14:37
Ubuntu dev lxc profile with cloud-init
config:
user.user-data: |
#cloud-config
package_upgrade: true
packages:
- vim
- nano
- git
- curl
- wget
@offlinehacker
offlinehacker / automerge.go
Created May 21, 2023 08:39
Automerge golang example
package main
import (
"fmt"
"time"
"github.com/automerge/automerge-go"
)
type S struct {
@offlinehacker
offlinehacker / rxdb-external-attachments-storage.ts
Created July 11, 2022 14:28
RxDB plugin to allow storage of attachments in external storage
import {
BulkWriteRow,
EventBulk,
RxAttachmentData,
RxAttachmentWriteData,
RxDocumentData,
RxDocumentDataById,
RxJsonSchema,
RxStorage,
RxStorageBulkWriteResponse,
@offlinehacker
offlinehacker / dom.ts
Last active March 9, 2022 15:43
DOM functions
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 March 2, 2022 11:52
Multipass cloud config to create VM with docker installed
#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 December 1, 2021 14:28
Devcontainer env probe
#!/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 November 23, 2021 12:32
Subscribe to ERC20 Transfer events
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)",
];