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
@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'));
@iamandrewluca
iamandrewluca / GONE.md
Last active November 4, 2021 09:18
Git alias to remove all local branches that are gone on remote

Create alias manually in ~/.gitconfig file (recommened):

[alias]
	gone = "!f() { git fetch --all --prune; git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D; }; f"

Create alias (problematic):

@iamandrewluca
iamandrewluca / README.md
Last active December 23, 2022 11:47
Adjust repository field in package.json for all packages in a monorepo

Update package.json repository field to point to directory in a monorepo setup

Run Gist using npx and zx in repository folder

npx zx https://gist.githubusercontent.com/iamandrewluca/5cc85b56a595056f0099d04ed6dd8a79/raw/run.mjs \
--repository="https://github.com/facebook/react.git" \
--homepage="https://reactjs.org" \
--ignore="fixtures" \
--space="2"