Skip to content

Instantly share code, notes, and snippets.

View martinratinaud's full-sized avatar
😀

Martin Ratinaud. Web Solutions Creator. martinratinaud

😀
View GitHub Profile
@martinratinaud
martinratinaud / email.html
Last active April 16, 2023 17:11
Display subtitle in email clients
<html>
<head>
<style type="text/css">
.preheader {
display: none;
max-height: 0;
overflow: hidden;
visibility: hidden;
font-size: 0;
color: transparent;
@martinratinaud
martinratinaud / .bashrc
Created April 7, 2023 12:29
Compress mp4 on mac using ffmpeg
video_compress() {
filename_without_extension="${input_file%.*}"
extension="${input_file##*.}"
output_file="${filename_without_extension}-compressed.${extension}"
ffmpeg -i "$input_file" -vcodec libx264 -crf 23 -acodec aac -strict -2 -movflags faststart "$output_file"
}
@martinratinaud
martinratinaud / Scraper.ts
Last active April 7, 2023 10:49
Check backlink existence and rel after buying them
import axios, { AxiosRequestConfig } from 'axios';
import { JSDOM } from 'jsdom';
export default class Scraper {
public JSDOM = JSDOM;
constructor() {}
async getUrl(url: string, axiosConfig?: AxiosRequestConfig) {
const { headers, ...options } = axiosConfig || {};
@martinratinaud
martinratinaud / filter-boolean.js
Created April 3, 2023 07:45
One Liner to filter empty values from an array
// One-Liner to filter all empty values from an array
const words = ["Follow", undefined, "@martinratinaud", null, '', "now!"]
const sentence = words.filter(Boolean)
console.log(sentence.join(" ")) // Follow @martinratinaud now!
@martinratinaud
martinratinaud / countries-translation.js
Created March 9, 2023 04:52
Get translated country names in javascript
const frRegionNames = new Intl.DisplayNames(["fr"], { type: 'region' });
frRegionNames.of("US") // 👉 'États-Unis'
const enRegionNames = new Intl.DisplayNames(["en"], { type: 'region' })
enRegionNames.of("US") // 👉 'United States'
const esRegionNames = new Intl.DisplayNames(["es"], { type: 'region' })
esRegionNames.of("US") // 👉 'Estados Unidos
@martinratinaud
martinratinaud / .gitconfig
Last active December 19, 2024 18:45
Awesome Git Configuration
[alias]
# shortcuts
c = commit
co = checkout
cp = cherry-pick
f = fetch
# enhancements
d = diff -- ':!package-lock.json' ':!yarn.lock' # Do not show lock files when diffing
ds = diff --staged -- ':!package-lock.json' ':!yarn.lock' # Do not show lock files when diffing staged files
@martinratinaud
martinratinaud / github-action.yml
Created April 1, 2022 10:12
Twitter optimal cron
name: optimal-post-on-twitter
on:
schedule:
- cron: '58 17 * * MON' # time adapted for NY timezone
- cron: '49 17 * * MON'
- cron: '32 13 * * TUE'
- cron: '58 17 * * TUE'
- cron: '49 21 * * TUE'
- cron: '32 13 * * WED'
“Great people are those who make others feel that they, too, can become great.”
— Mark Twain
“Action is the universal language of success.”
— Dr. Steve Maraboli
@martinratinaud
martinratinaud / remove-unwanted-from-git.sh
Created August 9, 2021 04:03
Remove a password (or unwanted string) commited in github (or gitlab) from git history
#!/bin/bash
git filter-branch --tree-filter "find . -name 'ops/roles/ota/files/.env' -exec sed -i -e \
's/<thepasswordtoremove>/***REMOVED***/g' {} \;"
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push --force --all
# If this commit was hosted on github, you will still be able to access the failing commit on the web
# which is not what you want
# This is because GitHub needs to run garbage collection and this will be done manually upon request
@martinratinaud
martinratinaud / extractDomainName.ts
Last active August 3, 2021 09:02
Extract domain name without subdomain from any url in javascript
const extractDomainName = (url:string) => {
const [extension, domain] = new URL(url).hostname.split('.').reverse();
return `${domain}.${extension}`;
}