Skip to content

Instantly share code, notes, and snippets.

@YohannParis
YohannParis / recover-deleted-branch.sh
Created February 21, 2024 14:00 — forked from umayr/recover-deleted-branch.sh
How to recover a deleted branch
## Pre-requisite: You have to know your last commit message from your deleted branch.
git reflog
# Search for message in the list
# a901eda HEAD@{18}: commit: <last commit message>
# Now you have two options, either checkout revision or HEAD
git checkout a901eda
# Or
git checkout HEAD@{18}
@YohannParis
YohannParis / github_to_things.sh
Created November 10, 2023 20:39
Bash script to synchronize GitHub task to Things.app
#!/bin/bash
# Script to sync GitHub tasks with Things locally
# Run this script with a cron job every hour on weekdays from 8 AM to 6 PM.
# Commands to make it happen:
# > brew install jq
# > chmod +x script.sh
# > crontab -e
# > 0 8-18 * * 1-5 /path/to/github_to_things.sh
// Core assets
let coreAssets = [];
// On install, cache core assets
self.addEventListener('install', function (event) {
// Cache core assets
event.waitUntil(caches.open(coreID).then(function (cache) {
for (let asset of coreAssets) {
cache.add(new Request(asset));
# Really simple using ffmeg
ffmpeg -i video.mov -filter_complex "[0:v] fps=12,scale=960:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" -f gif video.gif
const cities = [
[-79.41, 43.66], // Toronto
[-73.58, 45.5], // Montreal
[-114.08, 51.08], // Calgary
[-75.7, 45.41], // Ottawa
[-63.6, 44.65], // Halifax
[-64.79, 46.09], // Moncton
[-123.13, 49.25], // Vancouver
[-63.13, 46.23], // Charlottetown
[-106.66, 52.13], // Saskatoon
@YohannParis
YohannParis / canada-postalCode-regEx.txt
Created September 10, 2019 17:29
[regex] Canada postal code, strict.
/**
* Regular expression to test string is a proper Canadian postal code.
* H0H H0H, H0H0H0, H0H-H0H, and h0h0h0 formats are valid.
*/
/^[ABCEGHJ-NPRSTVXY][0-9][ABCEGHJ-NPRSTV-Z][ -]?[0-9][ABCEGHJ-NPRSTV-Z][0-9]$/i
@YohannParis
YohannParis / [regex] find orphans
Last active July 30, 2019 20:34
Regular Expression to find orphans at the end of paragraphs
([\w,]+) ([$\w]{1,7}[.!:\?”…"']*)</(.*)>\n
// Analytics
dataLayer.push({
'event': 'Interactive',
'category': 'Interactive',
'action': 'ACTION',
'label': 'LABEL'
});
@YohannParis
YohannParis / basic-sticky.js
Created December 13, 2016 19:58
Easy and quick way to add a sticky element.
var header = document.querySelector('.header');
var origOffsetY = header.offsetTop;
function onScroll(e) {
window.scrollY >= origOffsetY ? header.classList.add('sticky') :
header.classList.remove('sticky');
}
document.addEventListener('scroll', onScroll);
@YohannParis
YohannParis / SmoothScroll.js
Created August 16, 2016 20:50
Easy way to smoothscroll to an element — http://jsfiddle.net/DruwJ/1/
window.smoothScrollTo = (function () {
var timer, start, factor;
return function (target, duration) {
var offset = window.pageYOffset,
delta = target - window.pageYOffset; // Y-offset difference
duration = duration || 1000; // default 1 sec animation
start = Date.now(); // get start time
factor = 0;