Skip to content

Instantly share code, notes, and snippets.

View Utopiah's full-sized avatar

Fabien Benetou Utopiah

View GitHub Profile
@Utopiah
Utopiah / caption.scm
Created October 13, 2019 22:32
Gimp script to prepare the captionning of an image
(define (script-fu-add-caption image layer)
(define offset 20)
(define width (car (gimp-image-width image)))
(define height (car (gimp-image-height image)))
(define third (* 2 (/ height 3)))
(define theLayer (car (gimp-layer-new image width (/ height 3) RGB-IMAGE "transparent" 40 LAYER-MODE-NORMAL)))
(gimp-drawable-fill theLayer FILL-WHITE)
(gimp-layer-translate theLayer 0 third)
(gimp-image-insert-layer image theLayer 0 -1)
@Utopiah
Utopiah / docker_helloworld.txt
Created November 2, 2019 11:09
failed: docker run hello-world
root@ks:~# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Extracting 977B/977B
docker: failed to register layer: Failed to mount; dmesg: <4> [<ffffffff81d415ec>] ret_from_fork+0x7c/0xb0
<4> [<ffffffff810dbd90>] ? __kthread_unpark+0x50/0x50
@Utopiah
Utopiah / docker_warnings.txt
Created November 2, 2019 11:18
docker warnings from docker info
WARNING: No kernel memory limit support
WARNING: No kernel memory TCP limit support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
WARNING: No cpu shares support
WARNING: the devicemapper storage-driver is deprecated, and will be removed in a future release.
WARNING: devicemapper: usage of loopback devices is strongly discouraged for production use.
Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
Verifying my Blockstack ID is secured with the address 14bN6frKyzGCUoWLMVhcKWpf92vXdoQKWP https://explorer.blockstack.org/address/14bN6frKyzGCUoWLMVhcKWpf92vXdoQKWP
var d = new Date();
var timezoneOffset = d.getTimezoneOffset() / -60;
var EDT = 4
document.querySelector(".xl889183").innerHTML = document.querySelector(".xl889183").innerHTML.replace("EDT","CET")
var times = document.querySelectorAll(".xl689183, .xl699183, .xl859183");
for (var eventTime of times) {
var modHour = Number ( eventTime.innerHTML.match(/(.*):/)[1] ) + EDT + timezoneOffset
if (modHour<12) modHour+=12
var modMinute = eventTime.innerHTML.match(/:(.*) /)[1]
eventTime.innerHTML = modHour+":"+modMinute;
# Using iwatch to make a dedicated directory for automatic conversion
# iwatch -c '~/bin/webp_to_gif.sh %f gifs/%f' -e create . -d
FILE=$1
OUT=$2
for i in `seq 0 1 $(webpmux -info $FILE|grep frames|sed "s/.*: //")`; do
webpmux -get frame $i $FILE -o /tmp/f_$i.webp; convert /tmp/f_$i.webp /tmp/f_$i.png;
# part of webp tools https://developers.google.com/speed/webp/download
done;
for i in `seq 0 1 9`; do mv /tmp/f_$i.png /tmp/f_0$i.png; done;
@Utopiah
Utopiah / hubs_PDFs_pinning.js
Last active March 4, 2021 07:41
Pinning all PDFs present in a Mozilla Hubs scene
var PDFs = AFRAME.scenes[0].querySelectorAll("[media-pdf]");
for (var pdf of PDFs) {
NAF.utils.getNetworkedEntity(pdf).then(networkedEl => {
const mine = NAF.utils.isMine(networkedEl)
var owned = NAF.utils.takeOwnership(networkedEl)
networkedEl.setAttribute("pinnable", "pinned", true )
})
}
@Utopiah
Utopiah / hubs_PDFs_saved_for_transition.js
Created March 31, 2020 13:27
Locating PDFs with the radius of a predefined entity e.g. where to read/write docs
var writeTarget = document.querySelector(".WritingPlatformGroup .No_2_Pencil_")
var gltfs = document.querySelectorAll("[gltf-model-plus]")
var mostRecentGLTF = gltfs[gltfs.length-1]
var PDFs = AFRAME.scenes[0].querySelectorAll("[media-pdf]");
for (var pdf of PDFs) {
NAF.utils.getNetworkedEntity(pdf).then(networkedEl => {
//const mine = NAF.utils.isMine(networkedEl)
//var owned = NAF.utils.takeOwnership(networkedEl)
//networkedEl.setAttribute("pinnable", "pinned", true )
@Utopiah
Utopiah / hubs_proximity_avatar_scale_trigger.js
Created March 31, 2020 13:51
Getting close to a target object, e.g. here latest added PDF, makes it grow for any avatar within a 5m radius
var avatars = document.querySelectorAll("[networked-avatar]")
var PDFs = AFRAME.scenes[0].querySelectorAll("[media-pdf]");
var mostRecentPDF = PDFs[PDFs.length-1]
if (scalingTrigger) clearInterval(scalingTrigger)
var scalingTrigger = setInterval(nearbyAvarScaleUp, 300)
function nearbyAvarScaleUp(){
for (var avatar of avatars) {
var dist = mostRecentPDF.object3D.position.distanceTo( avatar.object3D.position)
if (dist<5) mostRecentPDF.object3D.scale.addScalar( 0.1 )
var gltfs = document.querySelectorAll("[gltf-model-plus]")
var avatars = document.querySelectorAll("[networked-avatar]")
lamp1 = document.querySelector("#naf-72yyyrx")
var lamp2 = gltfs[gltfs.length-1]
// safer than picking the Nth glTF
console.log(
gltfs,
lamp1,
lamp2
)