Skip to content

Instantly share code, notes, and snippets.

View iamandrewluca's full-sized avatar
🚨
Git Inspector

Andrei Luca iamandrewluca

🚨
Git Inspector
View GitHub Profile
import { FunctionalComponent, isVNode, VNode, VNodeNormalizedChildren, createTextVNode, render, createVNode, createCommentVNode } from "vue";
function visit(nodes: VNodeNormalizedChildren, exits: Map<string, VNode>): VNodeNormalizedChildren {
if (!Array.isArray(nodes)) return nodes
return nodes.map(node => {
if (!isVNode(node)) return node
if (node.type !== HTMLCommentExit) {
node.children = visit(node.children, exits)
$$('.runtimeLabel')
.map(e => e.textContent.trim().replace('Length: ',''))
.map(text => {
const hasHours = text.includes('and')
const [hText, mText] = hasHours
? text.split(' and ')
: ['0 hrs', text]
const h = Number.parseInt(hText)
const m = Number.parseInt(mText)
return h * 60 + m
@iamandrewluca
iamandrewluca / README.md
Last active September 5, 2023 21:16
curs.md google function
<template>
<ComboboxOption as="template" :value="option" v-slot="{ selected, active }">
<li class="relative cursor-default select-none py-2 pl-10 pr-4" :class="{
'bg-teal-600 text-white': active,
'text-gray-900': !active,
}">
<span class="block truncate" :class="{ 'font-medium': selected, 'font-normal': !selected }">
{{ option.name }}
</span>
<span v-if="selected" class="absolute inset-y-0 left-0 flex items-center pl-3"
<template>
<component :is="tag" class="relative">
<button
:class="[
'absolute top-0 h-full w-10 left-0 bg-gradient-to-r to-transparent',
startColor,
]"
:style="{ opacity: leftOpacity }"
@click="elementRef?.scrollBy({ left: -200, behavior: 'smooth' })"
/>
@iamandrewluca
iamandrewluca / README.md
Last active May 9, 2023 20:10
Instant Markdown editor

Instant Markdown editor in new tab

  1. Create a new bookmark
  2. To the link add data:text/html,
  3. After data:text/html, paste block below
  4. Save bookmark, and open it

First time it may take a while to load the library

@iamandrewluca
iamandrewluca / youtube-dl.md
Last active April 21, 2023 07:32
YouTube DL Commands

Download ringtones

https://github.com/yt-dlp/yt-dlp

yt-dlp -x --audio-format m4a --audio-quality 0 ...
# Ringtones should be no more then 35 seconds
mv *.m4a *.m4r
@iamandrewluca
iamandrewluca / generate-password.js
Last active April 3, 2023 16:21
Generate a password in browser #bookmarklet
javascript: void((function() {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
const upAlpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const lowAlpha = 'abcdefghijklmnopqrstuvwxyz';
const digits = '0123456789';
const specialChars = '!@#$.+';
const defaultSettings = confirm('Default settings');
const includeUpAlpha = defaultSettings ? true : confirm('Include: ' + upAlpha + ' ?');
const includeLowAlpha = defaultSettings ? true : confirm('Include: ' + lowAlpha + ' ?');
@iamandrewluca
iamandrewluca / open-localhost.js
Last active April 3, 2023 16:21
Open any URL with origin as localhost:3000 #bookmarklet
javascript: void((function () {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
/**
* Add your own mappers, first found will be used
* @type {{host: string, startsWith: string}[]}
*/
const hostMapper = [
{ startsWith: 'https://example.org', host: 'localhost:3000' },
{ startsWith: 'https://example.org/admin', host: 'localhost:3001' },
];
@iamandrewluca
iamandrewluca / zod-message-protocol.ts
Created February 22, 2023 22:20
Zod message protoco
import { z } from 'zod'
function createMessageProtocol<T extends z.ZodObject<{ type: z.ZodLiteral<string> }>>(events: T[]) {
// Add types from Zod
function createSender(fn: (data: any) => void) {
return (data: any) => fn(data)
}
// extract event types somehow
let types = events.map((e) => e.shape.type._type)