Skip to content

Instantly share code, notes, and snippets.

View rleroi's full-sized avatar
💻
Developing

R. Leroi rleroi

💻
Developing
View GitHub Profile
@rleroi
rleroi / .zshrc
Last active May 11, 2022 14:29
Aliases [Mac OS]
#####################################
# Some useful aliases for sharing. #
# Some by me, some found on the web #
#####################################
# Laravel Artisan
alias starthorizon='./artisan horizon'
alias stophorizon="kill \$(ps aux | grep 'php ./artisan horizon' | grep -v grep | head -n1 | awk '{print \$2}') 2> /dev/null && echo 'Horizon stopped'"
alias horizon='stophorizon; starthorizon;'
@rleroi
rleroi / longpress.js
Last active March 9, 2022 11:11
Mobile Longpress Directive for Vue
import debounce from 'lodash/debounce';
import Vue from 'vue';
// mobile longPress. usage: <div v-longpress="callbackFunction" /> you can specify an optional delay with v-longpress:1000="callbackFunction" (default is 300ms).
Vue.directive('longpress', {
bind(el, binding) {
let longPressTimeout = null;
el.addEventListener('touchstart', (e) => {
longPressTimeout = window.setTimeout(/*callback*/ binding.value, /*delay*/ binding.arg || 300);
});
@rleroi
rleroi / RequireToImport.js
Last active March 9, 2022 11:17
Replaces all inline `require('path').default` with `import Name from 'path'`
/*
* Replaces all inline `require('path').default` with `import Name from 'path'`
* Adding them as imports to the top of the file.
* Usage: node RequireToImport.js dir [dry]
*/
const glob = require("glob")
const path = require('path');
const fs = require('fs');
@rleroi
rleroi / whatsapp-qr.html
Last active July 14, 2022 13:42
Generate a WhatsApp QR-code with custom logo in the middle
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/awesome-qr/2.1.5-rc.0/awesome-qr.min.js" integrity="sha512-UpkZj9Z6XEPriWyGB7t7Hf4la5r6kLnxVzmjSpxqn9MFScD2m+m9QZyhKLOJW6lYTgGQB9UPEciaLizU0yZUeA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
async function generate(input) {
let file = input?.files?.[0];
let logo = null;
if (file) {
logo = window.URL.createObjectURL(file);
@rleroi
rleroi / gtp3-worker.js
Last active December 7, 2022 13:51
Generate short description for Trengo with GPT3, runs on Cloudflare Workers
addEventListener("fetch", (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.stack, { status: 500 })
)
);
});
const paused = false;