Skip to content

Instantly share code, notes, and snippets.

@prantlf
prantlf / icon.for.subtype.txt
Created January 15, 2021 19:00
How to assign a custom icon to a specific subtype.
src/icons/images/mytype.svg:
The icon image content.
src/icons/icons.css:
.binf-widgets .myext-mytype {
background-image: url('images/mytype.svg');
}
@prantlf
prantlf / icon.for.dwg.documents.txt
Created January 15, 2021 19:01
How to assign a custom icon to AutoCAD drawings.
src/icons/images/dwg.svg:
The icon image content.
src/icons/icons.css:
.binf-widgets .acad-mime-dwg {
background-image: url('images/dwg.svg');
}
@prantlf
prantlf / open.pws.txt
Created January 27, 2021 21:09
How to add a menu item opening Personal Workspace to the user profile menu.
src/commands/profile.menuitems.js (add menu items):
define(function () {
return {
profileMenu: [
{
signature: 'myext-open-pws',
name: 'Go to Personal Workspace',
group: 'others'
}
@prantlf
prantlf / trust-npm.sh
Last active March 20, 2022 17:33
Look for unreliable package authors
#!/bin/sh
# Look for NPM modules of the authors below in the local node_modules.
# Author of left-pad unpublished their modules from the NPM registry,
# which broke a lot of packages.
# https://www.theregister.com/2016/03/23/npm_left_pad_chaos/
# https://medium.com/@mproberts/a-discussion-about-the-breaking-of-the-internet-3d4d2a83aa4d
# https://blog.npmjs.org/post/141577284765/kik-left-pad-and-npm
# https://www.reddit.com/r/programming/comments/4bjss2/an_11_line_npm_package_called_leftpad_with_only/
@prantlf
prantlf / convertPointFromPageToNode.js
Created December 1, 2022 20:05 — forked from Yaffle/convertPointFromPageToNode.js
function to get the MouseEvent coordinates for an element that has CSS3 Transforms
/*jslint plusplus: true, vars: true, indent: 2 */
/*
convertPointFromPageToNode(element, event.pageX, event.pageY) -> {x, y}
returns coordinate in element's local coordinate system (works properly with css transforms without perspective projection)
convertPointFromNodeToPage(element, offsetX, offsetY) -> {x, y}
returns coordinate in window's coordinate system (works properly with css transforms without perspective projection)
*/
@prantlf
prantlf / crash-ref.vsh
Last active April 21, 2024 15:27
Crashes because of wrong recursive generics resolution of a struct reference in V
#!/usr/bin/env -S v run
// import json
// import os
import v.reflection { get_type }
// Declare structures covering a subset of a HAR file
struct HarContent {
size i64
@prantlf
prantlf / get-shady-element-by-xpath.js
Last active May 17, 2026 09:01
getShadyElementByXPath: returns an element by XPath, recognising elements in shadow DOM too.
// Returns an element by XPath, recognising elements in shadow DOM too.
//
// For example, a value returned by "Copy full XPath" in developer tools:
// "/html/body/div[1]/main/form/piwo-label[2]/piwo-input//input".
// The part "//" represents the shadow root divider.
//
// The input XPath has to:
// * be an absolute XPath starting with "/html".
// * include segments with tag names only, with an optional element index.
//