Skip to content

Instantly share code, notes, and snippets.

View boly38's full-sized avatar
🐔
🤖 cot cot cot 🎮

Vandeputte Brice boly38

🐔
🤖 cot cot cot 🎮
View GitHub Profile
// 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 / 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_mass.js
Created June 15, 2024 12:24
ReST API to detect X JPG files of bird using bird v2 public dataset from roboflow.com - from study : https://github.com/boly38/botEnSky/issues/57
// from: https://github.com/boly38/botEnSky/issues/57
// ----------------------------
// ReST API to detect bird - from blog : https://blog.roboflow.com/bird-detection-api/
// *** this file is doing identification of a target folder containing 1..N files having "JPG" as extension
import axios from 'axios';
import fs from 'fs';
import path from 'path';
import {fileURLToPath} from 'url';
const __filename = fileURLToPath(import.meta.url);
@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
@boly38
boly38 / gist:275d95f0da14d8d708a14df9e0bb7c4a
Created May 31, 2024 18:49
bluesky '@atproto/api' BskyAgent example using API directly : getPreferences - bluesky-social/bsky-docs#152
// for https://github.com/bluesky-social/bsky-docs/issues/152
import process from "node:process";
import {BskyAgent} from '@atproto/api';
const {"BLUESKY_USERNAME": identifier, "BLUESKY_PASSWORD": password} = process.env;// creds from env
const agent = new BskyAgent({"service": "https://api.bsky.social"})
await agent.login({identifier, password});
const response = await agent.api.app.bsky.actor.getPreferences();
const {preferences} = response.data
@boly38
boly38 / bluesky_mute_unmute_actor.js
Last active May 29, 2024 18:31
bluesky_mute_unmute_actor.js
// https://github.com/boly38/botEnSky/issues/26
import {BskyAgent} from '@atproto/api'
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc.js"
import timezone from "dayjs/plugin/timezone.js"
dayjs.extend(utc)
dayjs.extend(timezone)
/****** lib ******/
// from https://github.com/boly38/botEnSky/issues/7
// doc : https://docs.bsky.app/docs/tutorials/creating-a-post#images-embeds
import axios from "axios";
import {BskyAgent} from '@atproto/api'
const identifier = process.env.BLUESKY_EMAIL;
const password = process.env.BLUESKY_PASSWORD;
const service = "https://api.bsky.social";
const agent = new BskyAgent({service})
await agent.login({identifier, password});