Skip to content

Instantly share code, notes, and snippets.

View jurijsk's full-sized avatar
🤠
not the case

Jurijs Kovzels jurijsk

🤠
not the case
View GitHub Profile
@jurijsk
jurijsk / 0_reuse_code.js
Created April 2, 2016 23:02
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jurijsk
jurijsk / nlp-tools-comparison
Last active August 16, 2021 22:14
Comparison of Javascript/Typescript stemmers, lemmatizers, part of speech taggers and inflectors
//yarn add compromise stemmer en-inflectors wink-lemmatizer wink-pos-tagger wink-porter2-stemmer
//the goal is to find a way to generate all possible forms of word starting with just one form: any_word -> part of speech + lemma -> inflection
let terms = ['design', 'designs', 'designed', 'designing', 'designer', 'designers', 'designate', 'designated', 'designator', 'designators', 'ox', 'oxen', 'index', 'indices', 'criteria'];
console.group('stemmer');
console.time('stemmer');
import {stemmer} from 'stemmer';
console.timeLog('stemmer', 'loaded');
(function tryStemmer() {
const toc = document.getElementById('table-of-contents');
for (const x of document.querySelectorAll('h2, h3')) {
const id = x.innerText.replaceAll(/[^a-z0-9]/gi,'');
x.id = id;
const item = `<li><a href="#${id}">${x.innerText}</a></li>`;
switch (x.tagName.toLowerCase()) {
case "h2": toc.insertAdjacentHTML('beforeend', `${item}<ul></ul>`); break;
case "h3": [...toc.querySelectorAll('ul')]?.pop()?.insertAdjacentHTML('beforeend', item); break;
}
}
@jurijsk
jurijsk / linescaller.vue
Created May 7, 2023 00:11
Vuejs dynamic font size component aimed to scale the text to occupy all available space.
<script lang="ts">
import { nextTick, onMounted, onUnmounted, ref } from 'vue'
export default {
expose: [],
async mounted() {
const firstEl = <Text>this.$el;
if (!firstEl.nextElementSibling) {
return;
}
@jurijsk
jurijsk / dts.ts
Created June 8, 2023 21:16
Dirty way to generate props definitions from the object
let typestr = "";
for (const key in properties) {
if (Object.prototype.hasOwnProperty.call(properties, key)) {
const value = properties[key];
typestr += key + ": ";
let t = <string> typeof value;
t = t === "undefined" ? "unknown" : t;
if(t === "object" && Array.isArray(value)) {
let tt = <string> typeof value[0];
tt = tt === "undefined" ? "unknown" : tt;
@jurijsk
jurijsk / code.ts
Created July 25, 2024 17:00
Figma Plugin Styles to Local Variables swap
async function run() {
console.clear();
await figma.currentPage.loadAsync();
const dryRun = false;
const skipDevReady = true;
console.log(dryRun ? 'DRY RUN' : 'NORMAL RUN');