Skip to content

Instantly share code, notes, and snippets.

View Utopiah's full-sized avatar

Fabien Benetou Utopiah

View GitHub Profile
twitterGif(){
ffmpeg -hide_banner -i "$1" -filter_complex "[0:v] fps=12,$2split [a][b];[a] palettegen [p];[b][p] paletteuse" -y ~/ok.gif
# optional 2nd parameter for scale, e.g twitterGif largevideo.mp4 scale=600:-2,
}
twitterGifConvergeSize(){
SCALE=1
twitterGif $1 # try without changing the scale
while [ $(find ok.gif -size +10M -size -15M | wc -l) -lt 1 ]; do
if [ $(find ok.gif -size -15M | wc -l) -lt 1 ]; then
@Utopiah
Utopiah / cloud-init-template
Created June 14, 2022 05:21
doctl-scaling-immers
#cloud-config
package_update: true
packages:
- ca-certificates
- curl
- gnupg
- lsb-release
- git
write_files:
// to be used with a shortcut to get a DOI, e.g on Tridactyl on a Frontiers page :
// bind q js var ref = document.querySelector('div.References:hover'); var doi; if (ref) doi = ref.innerText.replace(/.*doi:/, "").split("\n")[0]; if (doi) fetch('http://localhost:3467/?doi='+doi).then(response => response.json()).then(data => alert(data.result));
/* to visually highlight what references have already been sent :
var ref = document.querySelector('div.References:hover');
if (ref) ref.innerText.replace(/.*doi/, "doi").split("\n")[0];
var text = ref.firstChild.lastChild.textContent.split("doi:");
ref.firstChild.lastChild.textContent = text[0];
var el = document.createElement("span");
el.style.background = "lightblue";
// for hubs, see https://twitter.com/utopiah/status/1495713341133791242
const owndomain = 'your-vartiste-glitch-remix.glitch.me'
const source = new EventSource('https://'+owndomain+'/sse');
source.onmessage = message => {
// hubs_utils from https://gist.github.com/Utopiah/1cfc123239fa2994569fc7c5c60b2928/
hubs_utils.getFirstElementFromPartialURL(owndomain+"/data/upload.glb")
.setAttribute("media-loader", "src", "https://"+owndomain+"/data/upload.glb#"+Date.now())
}
// to run on e.g hubs.mozilla.com in a room
fetch('/cloud').then(function (response) {
// limited due to CSP
return response.text();
}).then(function (html) {
var parser = new DOMParser();
var doc = parser.parseFromString(html, 'text/html');
var desc = doc.head.querySelector('meta[property="og:description"]').content;
var el = document.createElement("a-entity");
#!/bin/bash
for X in $(ls -d *highlights); do
TITLE=$(cat $(echo $X|sed "s/.highlights//").metadata | jq -r .visibleName)
HIGHLIGHTS=$(cat $X/*json | jq '.highlights[][] | {text} | add' -r)
DATA=""
IFS=$'\n'
for h in $HIGHLIGHTS; do
if [ $(echo $h|wc -c) -gt 2 ]; then
NEWDATA="{\"text\": \"$h\",\"title\": \"$TITLE\",\"author\": \"Fabien Benetou\"}"
if [ -z "$DATA" ]; then
#!/bin/bash
#
# opkg requirements :
# opkg install qpdf jq
# optionally imagemagick to generate the white page
# convert -size 1024x1448 xc:white /tmp/blank.pdf
#
# assumes ~/xochitl-data links to /home/root/.local/share/remarkable/xochitl/
#
# need to be able to renumber for each page added
#!/bin/bash
# could be stored on ~/bin/generateEpubTemplate on the reMarkable
mkdir -p META-INF OEBPS
echo '<?xml version="1.0" encoding="UTF-8" ?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
const TelegramBot = require('node-telegram-bot-api');
const { execSync } = require('child_process');
// replace the value below with the Telegram token you receive from @BotFather
const token = '123456789:ABCDEFGHIJKLMNOP';
const dlpath = 'https://api.telegram.org/file/bot'+token+'/'
// /home/root/bin/adddoc is an adaptation of addWithMetadataIfNew with exit 0 on new add
// from https://gist.github.com/Utopiah/e2d5c944bbd632e3ae0530e602977f45
// epubTemplate is based on https://gist.github.com/Utopiah/6728a2477de1c09be4150e43c439e0dd
@Utopiah
Utopiah / updateDefinitionsFromHighlights.sh
Last active August 26, 2023 15:24
On device offline dictionary for reMarkable
#!/bin/bash
#
# opkg requirements :
# opkg install 7z git jq
#
# git clone https://github.com/wordset/wordset-dictionary/
#
# assumes ~/xochitl-data links to /home/root/.local/share/remarkable/xochitl/
#
# warning ~/epubTemplate/ is required. See instead https://gist.github.com/Utopiah/119f5c96fae048609a2091f7f3d81f53