Skip to content

Instantly share code, notes, and snippets.

@rikonor
rikonor / main.go
Created January 19, 2019 02:43
Server Sent Events (SSE) Example in Go
package main
import (
"fmt"
"log"
"net/http"
"sync"
"time"
)
@rikonor
rikonor / main.py
Created July 21, 2023 21:23
Mock Cloudflare API with CoreDNS Update/Restart
from dataclasses import dataclass, field, fields
from http.server import BaseHTTPRequestHandler as BaseHandler
from http.server import HTTPServer
from typing import IO
from uuid import uuid4
import json
import os
import re
import socket
@rikonor
rikonor / main.go
Created February 3, 2021 04:43
ETH Convert JSON Keystore to Private Key
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"encoding/hex"
"encoding/json"
"flag"
"fmt"
@rikonor
rikonor / empty_mmdb.pl
Last active September 14, 2022 13:48
Generate empty mmdb files
# run 'mcpan MaxMind::DB::Writer::Tree' beforehand
use MaxMind::DB::Writer::Tree;
use Net::Works::Network;
my %types = ();
my $tree = MaxMind::DB::Writer::Tree->new(
ip_version => 4,
record_size => 24,
@rikonor
rikonor / main.py
Created September 1, 2020 01:16
Free disk-space in Python
import shutil
KB = 1024
MB = 1024 * KB
GB = 1024 * MB
shutil.disk_usage('/').free / GB
@rikonor
rikonor / bootstrap.js
Created August 17, 2021 20:00
[Strapi] Enable Google Provider via Bootstrap
"use strict";
const isFirstRun = async () => {
const pluginStore = strapi.store({
environment: "",
type: "type",
name: "setup",
});
const initHasRun = await pluginStore.get({ key: "initHasRun" });
@rikonor
rikonor / index.js
Created August 15, 2021 20:18
Context + useReducer
import { createContext, useContext, useReducer } from "react";
const initialState = {
isSigningIn: false,
isSignedIn: false,
};
const AuthContext = createContext(initialState);
const reducer = (state, action) => {
@rikonor
rikonor / base.pkr.hcl
Created February 14, 2021 05:25
Packer QEMU Pre-Seeded Debian Image
variable "iso_url" {
type = string
default = "https://cdimage.debian.org/cdimage/release/10.8.0/amd64/iso-cd/debian-10.8.0-amd64-netinst.iso"
}
variable "iso_checksum" {
type = string
default = "file:https://cdimage.debian.org/cdimage/release/10.8.0/amd64/iso-cd/MD5SUMS"
}
void main() {
var d = StubDoer(() {
print("Also doing...");
});
d = wrapWithTimes(100)(d);
d = wrapWithMetrics()(d);
d = wrapWithTracing()(d);
doStuff(d);
export MUSIC_PATH=/media/pi/CC72-D726
docker network create koel
docker run \
-d \
--name mysql \
--network koel \
-e MYSQL_ROOT_PASSWORD=123456 \
-e MYSQL_USER=koel \