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
let unit = `5" x 5' x 1-3/16"`
unit.split('x')
.map((v) => v.trim())
.map((v) => ({ value: removeUnit(v), unit: getUnit(v) }))
.map(({ unit, value }) => ({ unit, value: value.split('-') }))
.map(({ unit, value: [whole, fraction] }) => ({ unit, whole, fraction: splitFraction(fraction) }))
.map(({ unit, whole, fraction }) => ({ unit, value: parseInt(whole) + divideTuple(fraction) }))
.map(o => convertToInch(o))
.reduce((product, o) => product * o.value, 1)
@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 / README.md
Created February 22, 2022 18:16
Join mp4 files

Generate a file with all file names

for f in *.mp4; do echo file \'$f\' >> fileList.txt; done;

Merge all files together

ffmpeg -f concat -safe 0 -i fileList.txt -c copy output.mp4
@iamandrewluca
iamandrewluca / git-reset-author.sh
Last active December 1, 2021 15:52
Change commit author using a rebase
git rebase -x "git commit --amend --reset-author --no-edit" main
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)
// eslint-disable-next-line react-hooks/rules-of-hooks
let _store: ReturnType<typeof useReducer>
function useStore() {
const store = useRef(useReducer((s: any, a: any) => {
return {}
}, {}))
_store = _store ?? store.current
return _store
}
@iamandrewluca
iamandrewluca / add-script.js
Last active August 10, 2022 17:50
Add a script to page #bookmarklet
javascript: ((s) => {
"use strict";
if (s === atob("JXM=")) s = prompt();
/**
* More bookmarklets at
* https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2
* When used as a browser search engine `s` will be what user typed in address bar
*/
const script = document.createElement("script");
@iamandrewluca
iamandrewluca / new-quick-note.js
Created September 8, 2021 07:46
Open an empty tab as editable note #bookmarklet
javascript: void ((function() {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
// create an empty page data uri
// make it content editable
// open in new tab
})());
@iamandrewluca
iamandrewluca / google-meet-pip-you.js
Last active September 29, 2021 19:28
Google Meet, open your video Picture in Picture mode #bookmarklet
javascript: void ((function(userName = 'You') {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
function findUpElementByDataAttribute(element, attr) {
if (element) {
return element.dataset[attr] ? element : findUpElementByDataAttribute(element.parentElement, attr);
}
}
const usersElements = [...document.querySelectorAll('[data-initial-participant-id] [data-self-name]')];
@iamandrewluca
iamandrewluca / njt-default-github.js
Last active September 8, 2021 07:33
Extended njt.vercel.app but with GitHub as default, and TypeScript Search #bookmarklet
javascript: void ((function(query) {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
const [packageName, destination = 'g'] = decodeURIComponent(query).split('+').join(' ').split(' ');
if (destination === 'ts') {
window.location.href = `https://www.typescriptlang.org/dt/search?search=${packageName}`;
} else {
window.location.href = `https://njt.vercel.app/jump?to=${packageName} ${destination}`;
}
})('%s'));