Get youtube-dlc to work on Ubuntu 22.04

Had a bit of a faff getting youtube-dlc to work on ubuntu. This be the error codes for reference:

# after install with wget
/usr/bin/env: ‘python’: No such file or directory
# this is due to ubuntu running python from "$ python3"
# changing the line first line in "$ /usr/local/bin/youtube-dlc"
# and replacing python with python3 will not work and produces:
/usr/bin/env: ‘python’: No such file or directory
# "$ alias python=python3" will also not work.
# installing with pip gives following error:
zsh: command not found: youtube-dlc
# which is essentially produced as a result of how python
# works, and how documentation for python scripts are rarely
# aimed at non developers and noobs.Code language: PHP (php)

Solution, i.e. how to install/use youtube-dlc under ubuntu/linux

# install from the pip rep:
python3 -m pip install --upgrade youtube-dlc
# run like so:
python3 -m youtube_dlc\?v\=0000000

# optionally create alias:
alias ytd="python3 -m youtube_dlc"
# and run like so:
ytd\?v\=0000000Code language: PHP (php)

VS Code, virtualenvironment and Django; simple setup

Just found out that VS code is genious:

in shell, make a project folder:
>mkdir myproject
>cd myproject
>python3 -m virtualenv myproject_venv
>source myproject_venv/bin/activate
>pip install Django
>django-admin startproject myproject .Code language: Bash (bash)

Now if you open the “root” myproject folder, the one created on line 1, VS code will detect the django project and the virtual environment. So hit F5 to to run the server in debug mode.


Simple function to run javascript after specific content is loaded.
jQuery dependant.
Useful for dealing with resizing iframes after content is loaded to avoid scroll bars in the iframe. Also serves as an alternative to waitForKeyElement when tinkering with userscripts et.


waitForAsyncElement(selector, code, delay, timeout, fallback);

    selector: jQuery selector as string: "#yourElementHere"
    code:     function with code to run: function(){"code here"};
    delay:    delay in ms after element is loaded: default 30ms
    timeout:  stop execution if element is not loading: default 5000ms
    fallback: if timed out run fallback, example: function(){alert("async did not load")")}

waitForAsyncElement("#some-data", function(){
//Example with fallback:
waitForAsyncElement("#some-data", function(){
}, 30, 5000, function(){
      console.log("#some-data did not load");

Example for dealing with resizing iFrame after its loaded:
Note the extra 300ms delay to wait for iframe content to load,
iFrame.onload could have been used instead, but seem to fail on mobile.
onElementLoaded("#iFrame1", function(){
        var iFrame = document.getElementById('iFrame1');
        iFrame.height = iFrame.contentWindow.document.body.scrollHeight + 100;
}, 300);Code language: JavaScript (javascript)


var waitForAsyncElement = function(elementSelector, 
                               delay = 30, 
                               timeoutms = 5000, 
                               timeoutFallback = function(){return}){
    var intervl = setInterval(function(){
        if (jQuery(elementSelector).length){
            setTimeout(() => {callback()}, delay);
    }, 300);
    if (timeoutms !== 0){
        setTimeout(() => {
        }, timeoutms);
};Code language: JavaScript (javascript)


Public Domain or MIT, whichever suits you best. However please keep me in the loop if you build on the function, make and improvements and such 🙂

Save and load more reliably with in userscript, maybe.

So, been messing around with userscript lately, in tampermonkey. And hence had a few problems saving and loading with GM_setValue and GM_getValue. There are a couple of scrips out there to sort this for you, but none that i was able to get to work. So I’ve wrapped my own version up, which also compresses via LZstring. (google it).“float”, 12.34);

Continue reading

mirror website with wget

wget -r -np -k -nc --execute="robots = off" --wait=5 -E <url>

-r: recursive
-np: no parent directories
-k: convert links to local
-nc: no clobber, skip if file already downloaded
–execute=”robots = off”: ignore robots.txt
–wait=5: wait in between requests
-E: add .html to the end of filenames