Skip to content

Instantly share code, notes, and snippets.

@funkyremi
funkyremi / docker-compose.yml
Created January 19, 2021 20:23
Wordpress docker compose file
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
ports:
- 3306:3306
@funkyremi
funkyremi / network-monitor.sh
Created December 21, 2020 16:51
Reconnect to wifi or ethernet when down
#!/bin/bash
LOGFILE=/var/log/network-monitor.log
if /sbin/ifconfig eth0 | grep -q "inet"; then
echo "$(date "+%m %d %Y %T") : Ethernet OK"
else
echo "$(date "+%m %d %Y %T") : Ethernet connection down! Attempting reconnection." >>$LOGFILE
/sbin/ifconfig eth0 up
OUT=$?
@funkyremi
funkyremi / get-dom-element-promise.js
Last active September 30, 2019 12:44
Function that wait for an element to exist in DOM then return it.
export function getDomElement(selector = '', timeoutMs = 1000, pollIntervalMs = 10) {
const timeStart = performance.now();
return new Promise((resolve, reject) => {
const intervalId = setInterval(() => {
const timeNow = performance.now();
const element = document.querySelector(selector);
if (element) {
clearInterval(intervalId);
resolve(element);
} else if ((timeNow - timeStart) > timeoutMs) {
# Get remaining battery time
pmset -g batt|grep remaining|cut -d" " -f1,5
# Update Database (for locate)
sudo /usr/libexec/locate.updatedb
@funkyremi
funkyremi / netflix-captions-vtt.js
Last active February 19, 2024 07:45
Display Netflix Captions in PiP mode
// Hit refresh when playing a Netflix video and paste the following code in your console.
// This script will replace the native captions by WebVTT captions that will work in PiP mode.
// Use the code here to trigger PiP in safari: https://gist.github.com/funkyremi/9d7b70285282d532c3f8c964810e7bf9
const lang = 'fr';
const hideNetflixCaptions = (() => {
const style = document.createElement("style");
style.type = "text/css";
const hideCc = ".player-timedtext {display: none !important;}";

Copy and past the following code in your bookmark toolbar

javascript:var videos=document.getElementsByTagName("video");for(vid in videos)videos[vid].src&&videos[vid].webkitSetPresentationMode("picture-in-picture");

Update all docker images

docker images |grep -v REPOSITORY|awk '{print $1}'|xargs -L1 docker pull

Remove all containers

docker container rm $(docker ps -aq)

Remove all images

docker rmi $(docker images -aq)

See Docker Daemon logs

@funkyremi
funkyremi / screenshot-videos.js
Last active February 25, 2019 19:23
Capture picture from videos online
// Paste the following code in your developer console
var canvas = document.createElement('canvas');
var theVideo = document.querySelector('video');
canvas.width = theVideo.videoWidth;
canvas.height = theVideo.videoHeight;
canvas.getContext('2d').drawImage(theVideo, 0, 0, theVideo.videoWidth, theVideo.videoHeight);
var png = canvas.toDataURL('image/png');
var link = document.createElement('a');
link.href = png;
link.setAttribute('download', 'capture.png');
@funkyremi
funkyremi / 🎉.js
Created February 15, 2019 16:19
Auto scroll to Github best comment
// Auto scroll to Github best comment
// Choose one of the following method (Bookmark toolbar link or Browser console)
// Minified code (drag and drop to your bookmarks)
javascript:var bestCommentId;var bestScore=0;Array.from(document.querySelectorAll(".js-targetable-comment")).forEach(item=>{if(item.querySelector("button.reaction-summary-item")){let commentScore=0;Array.from(item.querySelectorAll("button.reaction-summary-item")).forEach(i=>{if(!!i.innerText){commentScore+=Number(i.innerText.replace(/\D/g,''))}});if(commentScore>bestScore){bestScore=commentScore;bestCommentId=item.id}}});console.log('Comment score',bestScore);location.href=`#${ bestCommentId }`;
// Original code (copy paste in your browser console)
var bestCommentId;
var bestScore = 0;
Array.from(document.querySelectorAll(".js-targetable-comment")).forEach(item => {
const codes = [
{
name: 'Action & Adventure',
code: '1365',
},
{
name: 'Action Comedies',
code: '43040',
},
{