Skip to content

Instantly share code, notes, and snippets.

View Lovor01's full-sized avatar
💭
I may be slow to respond.

Lovro Hrust Lovor01

💭
I may be slow to respond.
  • makeITeasy
  • Zagreb
View GitHub Profile

Modal dialog with form (or other element longer than dialog) on mobile device

HTML Requirements:

  • outer container element
  • inner content element

CSS

  • outer element position: fixed
  • inner element position: absolute

Eleventy tricks

set environment variable and run on windows

set var_name=blabla& npm run tralala

for cross system

We need cros-env then we can proceed Unix-way cross-env ELEVENTY_ENV=development eleventy --serve

@Lovor01
Lovor01 / revisions.md
Last active August 2, 2022 10:18
Clean WordPress revisions (using revisions wp cli extension)

Clean revisions

wp revisions dump --hard

without revisions addon

wp post delete $(wp post list --post_type='revision' --format=ids) --force
@Lovor01
Lovor01 / block&entity_details.md
Last active January 2, 2022 21:59
Block object & props

Block structure

Block object

{
  "clientId": "fcbeb231-6bf8-48a2-ac38-38d7f1919018",
  "name": "makeiteasy/schedule",
  "isValid": true,
  "validationIssues": [],
 "originalContent": "block content",
@Lovor01
Lovor01 / HowtoInject.md
Created February 21, 2022 19:46
Javascript injecting into DOM

This does not work!

document.body.append('<script src="https://www.google.com/recaptcha/api.js"></script>');

String is injected into the DOM, but script is not executed.

This does work!

Report block details

List block types

wp.blocks.getBlockTypes()

List block categories

wp.blocks.getCategories()

@Lovor01
Lovor01 / Largest.md
Created April 19, 2022 22:03
Find largest transients

Find largest transients

SELECT LENGTH(option_value), option_name FROM wp_options WHERE autoload='yes' ORDER BY length(option_value) DESC LIMIT 20;

@Lovor01
Lovor01 / Get link by slug.md
Created May 9, 2022 12:54
Get page link by slug
@Lovor01
Lovor01 / Transition helper.js
Created June 10, 2022 10:32
Javascript transition helper
/**
* Transitions from and to display-none do not work without JS
* helper function to do transitions and hide/show element after or before
* made global, so it can be used in other scripts
* @param {HTMLElement} parentElement parent element which gets toggled class
* @param {HTMLElement} actionElement action element which is hidden and shown and has transition
* @param {callable} callable show element
*/
window.transitionHelper = function (parentElement, actionElement, callable) {
if (! parentElement.classList.contains('toggled')) {
@Lovor01
Lovor01 / Change to InnoDB.md
Created August 29, 2022 15:41
Change database engines to InnoDB

SQL:

Run SQL and Run results :)

SET @DATABASE_NAME = 'name_of_your_db';

SELECT  CONCAT('ALTER TABLE `', table_name, '` ENGINE=InnoDB;') AS sql_statements
FROM    information_schema.tables AS tb
WHERE table_schema = @DATABASE_NAME