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 / 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)
@iamandrewluca
iamandrewluca / script.js
Created February 10, 2023 13:48
Unbookmark Mastodon bookmarks
let interval = setInterval(() => {
let bookmark = document.querySelector('.bookmark-icon')
if (bookmark) bookmark.click()
else clearInterval(interval)
}, 1000)
@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"
#!/usr/bin/env node
/**
* Makes quiz average from a bunch of Thinkific Quiz CSV files
*
* Prerequirements node and npm installed
* Drop this file in a folder only with Quiz CSVs exported from Thinkific
* Make this file executable by running `chmod +x quiz-totals`
* Install `csv` dependency by running `npm install csv`
* Execute it by giving output filename as argument
<script setup lang="ts">
import { shallowRef } from "vue";
import Recursive from "./components/Recursive.vue";
import { MyType } from "./my-type";
const allData = shallowRef<MyType[]>([
{
title: "Parent 1",
items: [
{
@iamandrewluca
iamandrewluca / README.md
Created September 30, 2022 11:02
Change video speed

Audio Speed increases when bigger then 1
Video Speed increases when lower then 1

Audio Speed = 1 / Video Speed

@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