Skip to content

Instantly share code, notes, and snippets.

View elkhadiy's full-sized avatar

EL KHADIRI Yassine elkhadiy

View GitHub Profile
@elkhadiy
elkhadiy / shrink4discord.cmd
Created March 23, 2021 00:49
needs ffmpeg and ffprobe on path or same folder (there are handy windows static builds on their website), then just drag'n'drop video file on it and let it crunch away
@ECHO off
CD /D %~p0
SET output=%~n1_8MB.mp4
FOR /F "usebackq" %%i in (`ffprobe -i %1 -show_entries format^=duration -v quiet -of csv^="p=0"`) do set seconds=%%i
SET /A "totalBitrate=64000/seconds"
SET overheadBitrate=100
SET audioBitrate=96
SET /A "videoBitrate=totalBitrate-audioBitrate-overheadBitrate"
ffmpeg -hide_banner -y -i %1 -c:v libx264 -b:v %videoBitrate%k -pass 1 -b:a %audioBitrate%k -f mp4 NUL && \
ffmpeg -hide_banner -i %1 -c:v libx264 -b:v %videoBitrate%k -pass 2 -b:a %audioBitrate%k "%output%"
@elkhadiy
elkhadiy / playlist_duration.js
Created January 14, 2019 15:41
youtube playlist add duration
let timedelta = document.getElementById("stats").firstElementChild.cloneNode(true);
timedelta.innerText = (seconds => `${Math.floor(seconds/3600)}:${Math.floor(seconds/60) % 60}:${Math.floor(seconds) % 60}`).call(this, Array.from(document.getElementsByClassName('ytd-thumbnail-overlay-time-status-renderer')).map(x => x.innerText.split(":").map(x => parseInt(x, 10)).reduce((acc, val) => acc * 60 + val)).reduce((acc, val) => acc + val));
document.getElementById("stats").insertBefore(timedelta, document.getElementById("stats").firstElementChild.nextSibling);
@elkhadiy
elkhadiy / file_picker.py
Created November 24, 2018 04:36
jupyter ipywidget file picker and browser / explorer
import os
import ipywidgets as widgets
class FilePicker(object):
"""ipywidget for filepicking
Display the widget in a notebook:
>>> file_picker = FilePicker()
@elkhadiy
elkhadiy / gist:1d9cf954825b6dabb5c5
Last active August 29, 2015 14:06
Get total amount of an amazon wish list for yurop people
var list = $$('span.a-color-price.a-size-base');
var total = 0;
for (i = 0; i < list.length; i++) {
var price = parseFloat(list[i].innerHTML.replace('EUR', '') .replace(',', '.'));
total += price;
}
console.log("Total amount of items in wish list = ", total, "€");