Skip to content

Instantly share code, notes, and snippets.

View boly38's full-sized avatar

Vandeputte Brice boly38

View GitHub Profile
@boly38
boly38 / xonotic_chat_songs.txt
Last active July 19, 2024 15:58
xonotic chat song alias shortcut
# list them all : [F8] then [2]
# alphanum order ASC
_hi
_gg
aaa
aaaa
air
ban?
bass
bastage
@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});
@boly38
boly38 / logtail_api.js
Last active May 27, 2024 15:36
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 / bluesky_post.js
Last active May 27, 2024 15:37
bluesky my first automated post
// from : https://github.com/boly38/botEnSky/issues/1
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});
const text = "Hey ! Ceci est un Post de PoC (fichier js de 8 lignes) & sera le seul test sur ce compte #bluesky #api #bot https://docs.bsky.app/docs/get-started";
await agent.post({text, createdAt: new Date().toISOString()}).then(console.log).catch(console.log)
import * as mineflayer from "mineflayer";
const username = process.env.BOT_USERNAME || 'SAMPLE[bot]';
const host = "127.0.0.1";
const port = process.env.MINECRAFT_SERVER_PORT || 25565; // /publish true adventure 25565
console.log(`chicken bot ${host}:${port}`)
const bot = mineflayer.createBot({host, port, username});
// Log errors and kick reasons:
bot.on('kicked', console.log)
@boly38
boly38 / Listing.js
Created March 23, 2022 12:18
Mongoose expireAt example
import mongoose from 'mongoose';
const { Schema } = mongoose;
const Listing = new Schema({
"listing_id": { type: Number, index: true, unique: true },
"title": String,
"expireAt": { type: Date, expires: 10 } // <========== TTL index here
});
export { Listing };