Skip to content

Instantly share code, notes, and snippets.

View wiledal's full-sized avatar
πŸ₯ƒ

Hugo Wiledal wiledal

πŸ₯ƒ
View GitHub Profile
@wiledal
wiledal / deploy.yml
Created August 21, 2023 06:48
Github Actions - Monorepo deploy workflow
# Deploy frontend after successful backend deployment in sequence
# If frontend changed, deploy only frontend
# If backend changed, deploy only backend
# If frontend and backend, deploy frontend after backend
name: "Deploy services"
on:
push:
branches: ["main"]
jobs:
@wiledal
wiledal / animate-advanced.js
Last active March 19, 2025 05:26
Tiny GSAP-style CSS animation library
/*
Tiny, smart, single-method animation library for CSS animations - TweenMax-style.
Returns a Promise that resolves when the transition has ended.
Usage:
Single element:
AnimationService.animate(element, time, to)
AnimationService.animate(element, time, from, to)
Multiple elements with stagger:
@wiledal
wiledal / template-literals-3-for-loops.js
Last active January 1, 2025 06:18
Template Literals example: For loops
/*
Template literals for-loop example
Using `Array(5).join(0).split(0)`, we create an empty array
with 5 items which we can iterate through using `.map()`
*/
var element = document.createElement('div')
element.innerHTML = `
<h1>This element is looping</h1>
${Array(5).join(0).split(0).map((item, i) => `
@wiledal
wiledal / typed-css-modules-in-nextjs.md
Last active July 9, 2024 08:38
Add typed css modules in nextjs
@wiledal
wiledal / pull_request_template.md
Last active November 17, 2023 08:46
PR Template

Description

Closes JIRA-XXXX

Type of change

  • πŸ› Bug fix
  • ✨ New feature
@wiledal
wiledal / try-catch.ts
Last active August 22, 2023 12:13
until.ts
/**
Value first, might be nicer
@example
const [value] = tryCatch(doSomething())
if (!value) {
// something went wrong
}
*/
const tryCatch = async <TSuccess, TError extends Error>(
@wiledal
wiledal / get-browser-platform.test.ts
Last active July 19, 2023 17:36
Get Browser Platform
import { getBrowserPlatform } from '@/src/lib/browser-platform/browser-platform';
const DESKTOP_UA =
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.82 Safari/537.36';
const IPHONE_UA =
'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1';
const ANDROID_UA =
'Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.91 Mobile Safari/537.36';
describe('browser-platform', () => {
@wiledal
wiledal / template-literals-2-for-each.js
Last active March 9, 2023 20:57
Template Literals example: for each
/*
Template literals forEach example
Using Array.map(), we can create a forEach within template literals.
*/
var items = [
{ name: 'Teddy' },
{ name: 'Dolores' },
{ name: 'William' },
{ name: 'Bernard' }
@wiledal
wiledal / automator-ffmpeg-scripts.sh
Last active February 10, 2023 08:31
OSX Automator FFMPEG scripts
# Convert a video file to 720p with 24fps
/opt/homebrew/bin/ffmpeg -i "$@" -preset slow -codec:a aac -b:a 128k -codec:v libx264 -pix_fmt yuv420p -b:v 2500k -minrate 1500k -maxrate 4000k -bufsize 5000k -vf scale=-1:720 -filter:v fps=24 "$@-converted.mp4"
# Simpler
/opt/homebrew/bin/ffmpeg -y -i "$@" -preset slow -codec:a aac -b:a 128k -codec:v libx264 -pix_fmt yuv420p -b:v 2500k -filter:v "scale=-2:720, fps=48" "$@-converted.mp4"
# Convert audio to .mp3
/opt/homebrew/bin/ffmpeg -y -i "$@" -vn -ar 44100 -ac 2 -b:a 192k "$@.mp3"
@wiledal
wiledal / template-literals-1-if-statements.js
Last active May 4, 2022 14:18
Template Literal Examples: if-statement
/*
Template literals if-statement example
Using a single-line conditional, we can create an if-statements within template literals.
*/
function makeHTML(title) {
return `
${title ? `
This element has a title, and it is "${title}"
` : `