Skip to content

Instantly share code, notes, and snippets.

View kearfy's full-sized avatar
👨‍💻
ABC - Always Be Coding

Micha de Vries kearfy

👨‍💻
ABC - Always Be Coding
View GitHub Profile
@kearfy
kearfy / batching.ts
Last active August 13, 2023 14:40
Simple TS batching function
// Sorry for the indentation size!
// Github does not let me change it and applied the wrong setting!
function batches<T>(unbatched: T[], batchSize: number) {
const numOfBatches = Math.ceil(unbatched.length / batchSize);
const batchIndexes = Array.from(
new Array(numOfBatches),
(_, i) => i * batchSize)
);
const batches = batchIndexes.map((i) =>
@kearfy
kearfy / output.json
Created July 28, 2023 13:03
SurrealQL recursion
[
{
"id": "recursion:five",
"links": [
"recursion:four",
"recursion:two"
],
"resolved": [
{
"id": "recursion:four",
@kearfy
kearfy / rename-field.sql
Created April 14, 2023 10:10
How to "rename" a field in SurrealDB
BEGIN;
-- Starting point
DEFINE TABLE test SCHEMAFULL;
DEFINE FIELD one ON test;
CREATE test:1 SET one = 123;
CREATE test:2 SET one = 456;
-- "rename" the field
DEFINE FIELD two ON test;
@kearfy
kearfy / guide.md
Last active April 13, 2023 12:58
Upgrade SurrealDB from beta-8 to beta-9 for docker users (unofficial, rough example)

Original source can be found here: https://discord.com/channels/902568124350599239/970338835990974484/1096046227528888340 This gist is a rough example on how to approach this migration in case you're using docker

Author nickmenow, careerlister

Guide to update docker running SurrealDB beta8 to beta9

Starting from a logged in prompt of your computer, EC2 instance, Virtual Machine or box:

  1. Follow the guide to download on your operating system the correct extra beta-8 release found here => https://surrealdb.com/docs/installation/upgrading/beta8-to-beta9 Unarchive it to a safe location - perhaps in a new folder. My example is in folder with path /home/ubuntu/beta8_extra