Skip to content

Instantly share code, notes, and snippets.

View oscarmarina's full-sized avatar

Oscar Marina oscarmarina

  • BBVA
  • Madrid, Spain
View GitHub Profile
import type {ReactiveController, ReactiveControllerHost} from 'lit';
/**
* A reactive controller that updates a host when slotted content changes and
* provides helper methods for checking and getting assigned slot content.
*/
export class SlotController implements ReactiveController {
private _host: ReactiveControllerHost & Element;
private _slotNames?: ReadonlyArray<string>;
@oscarmarina
oscarmarina / index.html
Created April 23, 2023 17:44 — forked from e111077/index.html
MWC Select working inside an MWC dialog
<!DOCTYPE html>
<head>
<script type="module" src="./simple-greeting.js"></script>
</head>
<body>
<simple-greeting name="World"></simple-greeting>
</body>
@oscarmarina
oscarmarina / toggle-ytp.js
Created May 29, 2023 21:16
Bookmark - Toggle the YouTube Bar/Controls
javascript: (function () {
var style = document.querySelector('#toggle-ytp');
if (style) {
style.remove();
} else {
var selector = '.ytp-chrome-top,.ytp-chrome-bottom';
style = document.createElement('style');
style.id = 'toggle-ytp';
style.textContent = selector + '{display:none;}';
document.head.appendChild(style);
- name: Check object
run: |
cat << OBJECT
${{ toJson(github.event) }}
OBJECT
@oscarmarina
oscarmarina / request-submit-polyfill.js
Created July 14, 2023 10:17
Requests to submit the form. Unlike submit(), this method includes interactive constraint validation and firing a submit event, either of which can cancel submission.
(prototype => {
if (typeof prototype.requestSubmit === 'function') {
return;
}
const validateSubmitter = (submitter, form) => {
if (!(submitter instanceof HTMLElement)) {
throw new TypeError('The submitter element is not of type HTMLElement');
}
if (submitter.type !== 'submit') {
@oscarmarina
oscarmarina / moveRowsWithKeywordToNewSheet.gs
Created November 14, 2023 21:05
Move Rows with Keyword
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Custom Menu')
.addItem('Move Rows with Keyword', 'moveRowsWithKeywordToNewSheet')
.addToUi();
}
function moveRowsWithKeywordToNewSheet() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var activeSheet = ss.getActiveSheet();
@oscarmarina
oscarmarina / context-meta.ts
Last active April 4, 2024 15:15
Lit playground context-consume-provide
import { ReactiveController, ReactiveControllerHost } from 'lit';
import {
createContext,
ContextProvider,
ContextConsumer,
Context,
ContextType,
} from '@lit/context';
@oscarmarina
oscarmarina / urlToPlainObject.js
Created April 9, 2024 09:03
converting-a-url-object-to-a-plain-object-in-java-scrip
// https://www.abeautifulsite.net/posts/converting-a-url-object-to-a-plain-object-in-java-script/
const url = new URL('https://api.chucknorris.io/jokes/random');
function urlToPlainObject(url) {
const plainObject = {};
for (const key in url) {
if (typeof url[key] === 'string') {
plainObject[key] = url[key];
@oscarmarina
oscarmarina / isFocusable.js
Last active June 25, 2025 02:34
Checks if an element is focusable - treewalker = walkComposedTree(this, NodeFilter.SHOW_ELEMENT, isFocusable);
/**
* Checks if an element should be ignored.
* @param {Element} element - The DOM element to check.
* @param {Array} [exceptions=['dialog', '[popover]']] - Array of Elements to ignore when checking the element.
* @returns {boolean} True if the element should be ignored by a screen reader, false otherwise.
*/
const isElementInvisible = (element, exceptions = ['dialog', '[popover]']) => {
if (!element || !(element instanceof HTMLElement)) {
return false;
}
@oscarmarina
oscarmarina / eslint.config.js
Last active October 17, 2024 16:59
eslint.config
// @ts-nocheck
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import importPlugin from 'eslint-plugin-import';
import {configs as wc} from 'eslint-plugin-wc';
import {configs as lit} from 'eslint-plugin-lit';
import tseslint from 'typescript-eslint';
import tsParser from '@typescript-eslint/parser';
import html from '@html-eslint/eslint-plugin';
import eslintConfigPrettier from 'eslint-config-prettier';