Skip to content

Instantly share code, notes, and snippets.

@boly38
boly38 / betterstack_api.js
Last active August 21, 2025 11:35
This NodeJs example file is an autonomous script that query betterstack telemetry api (historically called logtail) https://betterstack.com/docs/logs/api/ (rely on env variables)
/**
* source: https://gist.github.com/boly38/b3b41ad48c41a9e58dde577e39a0d48f
* This NodeJs example file is an autonomous script
* that query betterstack telemetry api (historically called logtail)
* https://betterstack.com/docs/logs/api/
*
* Usage example (update with YOUR values):
* export LOG_BETTERSTACK_SOURCE_TABLE_NAME=mySource_dev
* export LOG_BETTERSTACK_SOURCE_ID=7654321
* export LOG_BETTERSTACK_API_HTTP_REMOTELY_ENDPOINT=https://eu-REPLACE_ME-connect.betterstackdata.com
@boly38
boly38 / logtail_api.js
Last active August 20, 2025 18:37
Sample Node.js example that query logtail api : list sources, and query one source
// from : https://github.com/boly38/botEnSky/issues/15
const logtail_api_token = process.env.LOGTAIL_API_TOKEN;
// Source NAME - get it from source config UI : "Basic" > "Source ID" - it's a name not an int
const logtail_source_name = process.env.LOGTAIL_SOURCE_NAME;
// Source ID - get it from source url, or from results of get sources api - it's an int
const logtail_source_id = process.env.LOGTAIL_SOURCE_ID;
// Import Axios
@boly38
boly38 / promise_throw.js
Last active March 18, 2025 12:16
NodeJS, Promise and "throw"
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function promiseMethod() {
return Promise.resolve("ok");
}
// WARN WARN - this sample introduce some issue as #2757 is talking about : Event blockUpdate:(x, y, z) did not fire within timeout of 5000ms
// use FIXED version below instead of this
export const isAirBlock = b => b && b.name === 'air';
/**
* Find a clear position dégagée next to the bot to place a bloc.
* @param {Bot} bot - Mineflyer Bot Instance
* @param {number} range - Around bot max range to explore.
* @returns {pos} - A valid position or null if no one is found.
*/
export const findClearPosition = (bot, range = 3) => {
@boly38
boly38 / WaitForAllFuturesTest.java
Last active November 27, 2024 11:21
Given an executor, a set of tasks, and a time limit to process them all : -> what is the way to detect & interrupt task properly on timeout ? -> could you explain the diff between two tests regarding thread flag ^^ ?
package com.mycompany;
import static java.util.concurrent.Executors.newFixedThreadPool;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
package com.example.company.interceptors;
import java.io.IOException;
import java.net.URI;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
@boly38
boly38 / README.md
Last active November 18, 2024 06:15
Use KeePass from command line (KPScript plugin) in order to generate project secrets file

Use Keepass to store and generates env file

Scripts

  • keepassEnv.sh is linux-compatible (also git bash for windows works)
  • keepassEnv.bat is windows-compatible (could be improved)
  • keepassCheckout.sh is linux-compatible and allow to read multiple files in one shoot

each script may be self-documented

Usage

@boly38
boly38 / umamiNodeSample.js
Last active October 16, 2024 18:43
Umami - Node.Js library sample
// https://github.com/umami-software/website/issues/191
// https://umami.is/docs/api/node-client
import umami from "@umami/node"; // https://www.npmjs.com/package/@umami/node
const hostUrl = "https://cloud.umami.is";
const websiteId = process.env.UMAMI_WEBSITE_ID || false; // umami instance id
const websiteDomain = process.env.UMAMI_WEBSITE_DOMAIN || "myapp.example.com";
if (!websiteId) {
throw new Error('Please set UMAMI_WEBSITE_ID env');
}
@boly38
boly38 / xonotic_chat_songs.txt
Last active August 14, 2024 12:09
xonotic chat song alias shortcut
# list them all : [F8] then [2]
# alphanum order ASC
_hi
_gg
_gn3
_nice3
aaa
aaaa
air
ban?
@boly38
boly38 / roboflow_bird_v2_test.js
Last active July 1, 2024 07:05
ReST API to detect bird using bird v2 public dataset from roboflow.com - from study : https://github.com/boly38/botEnSky/issues/57
/// gist : https://gist.github.com/boly38/5752000289342895a6008e53df2c6c9f
// from: https://github.com/boly38/botEnSky/issues/57
// ----------------------------
// ReST API to detect bird - from blog : https://blog.roboflow.com/bird-detection-api/
// API_KEY - REQUIRED - export ROBOFLOW_API_KEY=xxxx
// https://app.roboflow.com / use public plan free and get your api key under profile
const api_key = process.env["ROBOFLOW_API_KEY"] || "unauthorized";
// bird v2 public dataset based on JS sample provided