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 / speak-selected-text.js
Last active September 18, 2022 05:01
Will speak any select text from page #bookmarklet
javascript: void ((async () => {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
let interval = 500;
const intervalId = setInterval(() => {
interval += 500;
if (interval > 5000) { return; }
if (window.speechSynthesis.getVoices().length !== 0) {
clearInterval(intervalId);
@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 / MyModel.php
Last active June 17, 2022 12:34
typo3 extbase categories
<?php
/**
* categories
*
* \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category>
* @lazy
*/
protected $categories;
/**
* MyModel constructor.
@iamandrewluca
iamandrewluca / oss-tools.md
Last active May 20, 2022 07:18
Open source software tools
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"meta": {
"version": "1.0.0",
"lastModified": "2022-04-23",
"canonical": "https://raw.githubusercontent.com/iamandrewluca/jsonresume/main/resume.json"
},
"basics": {
"name": "Andrew Luca",
"email": "iamandrewluca@gmail.com",
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
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
@iamandrewluca
iamandrewluca / permissions.ts
Last active November 10, 2021 13:39
permissions based rendering
import { AdminUserRole } from 'gto-patterns'
/**
* A string combined of resource and method separated by a colon `:` e.g. 'user:get'
* Desired to keep resource as a singular word
* Nested resources can be separated by a slash `/` e.g. 'user/account-type:edit'
* A resource can contain one of owned fields separated by `@` e.g. 'user@registrationDate:get'
* Default methods are list, get, create, update, delete (https://cloud.google.com/apis/design/standard_methods)
* Custom methods can be added e.g. block, import, assign, generate
* These rules are invented, if anyone has a better idea how to categorize actions, please suggest.
@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):