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
// 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 };
@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 / rabbitStateAndPurge.sh
Last active August 13, 2019 08:34
shell script to state and purge RabbitMQ queues using RabbitMQ Management HTTP API (https://pulse.mozilla.org/api/) and Jq JSON Processor (https://stedolan.github.io/jq/) #rabbitmq #purge #bash #script #jq #json
#!/bin/bash
#
# This Gist is under MIT License
#
# Copyright 2018 Orange - Brice Vandeputte
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
@boly38
boly38 / NetUtils.java
Last active February 10, 2019 17:44
Java Simple Socket Check
package com.github.gist.it;
import java.net.InetSocketAddress;
import java.net.Socket;
public class NetUtils {
/**
* check if a given server is listening on a given port in the limit of timeoutMs
* @param serverHost server hostname (or ip)
@boly38
boly38 / ldjson_1_article_N_comments_using_graph.json
Created July 5, 2018 11:08
Repeating Comment in JSON-LD Article (Schema.org specifications)
{
"@context": "http://schema.org",
"@graph": [
{
"@type": "Article",
"@id": "/articles/foobar",
"url" : "https:\/\/exemple.com/article?id=1234",
"author" :{"@type" : "Person","name" : "Didier"},
"image" : "https:\/\/exemple.com/article.jpg",
"mainEntityOfPage" : "https:\/\/exemple.com",
@boly38
boly38 / ldjson_escape_room.html
Last active June 28, 2018 17:23
Gist describing constraint for ld-json string value
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>json slash try</title></head>
<body>
I am a sample html body
with embedded ld+json (between lines X and X')<br/>