Skip to content

Instantly share code, notes, and snippets.

View VlatkoStojkoski's full-sized avatar
🎯
Focusing

Vlatko Stojkoski VlatkoStojkoski

🎯
Focusing
View GitHub Profile
@VlatkoStojkoski
VlatkoStojkoski / next.config.ts
Created February 29, 2024 00:06
next.config.ts #2
/** @type {import('next').NextConfig} */
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config, { isServer, dev }) => {
if (isServer) {
// Copy the proto files to the server build directory
@VlatkoStojkoski
VlatkoStojkoski / next.config.ts
Created February 29, 2024 00:06
next.config.ts #1
/** @type {import('next').NextConfig} */
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config, { isServer }) => {
if (isServer) {
// Copy the proto files to the server build directory
echo -ne '\e]11;#000000\a'
HOST_NAME=$HOSTNAME
source ~/.nvm/nvm.sh
nvm use lts/*
shopt -s autocd
shopt -s histappend
export PATH=$PATH:$HOME/bin
const titleEl = document.querySelector('.training-content > table:nth-child(1) > caption:nth-child(1)')
const sortButton = document.createElement('button');
sortButton.innerText = 'Сортирај';
sortButton.style.setProperty('float', 'right');
sortButton.addEventListener('click', () => {
document.querySelector('body > div.page-container > div.main > div.main-content > div:nth-child(3) > div > table > tbody').innerHTML = [...document.querySelectorAll('body > div.page-container > div.main > div.main-content > div:nth-child(3) > div > table > tbody > tr > td:nth-child(5) > a')].sort((a, b) => +a.innerText.match(/(?<= \()\d+/)[0] > +b.innerText.match(/(?<= \()\d+/)[0] ? -1 : +a.innerText.match(/(?<= \()\d+/)[0] < +b.innerText.match(/(?<= \()\d+/)[0] ? 1 : 0 ).map((a) => a.parentElement.parentElement.outerHTML).join('');
});
titleEl.appendChild(sortButton);
@VlatkoStojkoski
VlatkoStojkoski / mendo-sort.js
Created November 17, 2022 18:06
Sort mendo.mk tasks from easiest to hardest
document.querySelector('body > div.page-container > div.main > div.main-content > div:nth-child(3) > div > table > tbody').innerHTML = [...document.querySelectorAll('body > div.page-container > div.main > div.main-content > div:nth-child(3) > div > table > tbody > tr > td:nth-child(5) > a')].sort((a, b) => +a.innerText.match(/(?<= \()\d+/)[0] > +b.innerText.match(/(?<= \()\d+/)[0] ? -1 : +a.innerText.match(/(?<= \()\d+/)[0] < +b.innerText.match(/(?<= \()\d+/)[0] ? 1 : 0 ).map((a) => a.parentElement.parentElement.outerHTML).join('');

Simple HTML templating script

Usage

The script grabs all the HTML pages from a src folder, and the separate components from the components folder and injects the components from the folder into the pages.

Injecting a component in a page

src/page-1.html

={=components/component-name.component.html(prop-1=prop 1 value;prop-2=prop 2 value)=}=

This gets the component code from the specified components folder path and replaces it in the page code where the injection is written.

console.log([...document.querySelectorAll('tr > td.solved:nth-child(1)')].map((el) => +el.innerText).join(';'));