The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,226 other subscribers

Archive for the ‘Scripting’ Category

Why I try to keep an online copy of my bookmarklets in html instead of Markdown

Posted by jpluimers on 2023/06/01

As Chrome mangles Bookmarklets to a partially escaped form (I think using Percent encoding), I first tried to document my Bookmarklets in Markdown so I could easier edit them and copy these JavaScript links  to various browsers. That failed, because the html rendered from the Markdown didn’t contain the links any more. So I now use plain html for documenting them which is a pain to edit but works.

[Wayback/Archive] Some bookmarklets hosted as [Wayback/Archive] Some bookmarklets – cached 1 minute – throttled and [Wayback/Archive] Some bookmarklets – cached 1 year – CDN.

This is why:

  1. Technically you can include JavaScript for Bookmarklets in Markdown documents both as Markdown links (either with escapes or by splitting reference and link in two pieces) and html links (as embedding html in Markdown is allowed): [Wayback/Archive] Bookmarklet link in Markdown document – Stack Overflow (thanks [Wayback/Archive] Adam Haile, [Wayback/Archive] Zombo and [Wayback/Archive] stevemegson)
  2. Because of security reasons, many hosters will filter out JavaScript when transforming Markdown in html [Wayback/Archive] Embed JavaScript in GitHub README.md – Stack Overflow (thanks [Wayback/Archive] Matt Smith and [Wayback/Archive] coyotte508)

Searches: [Wayback/Archive] markdown javascript in link – Google Search and [Wayback/Archive] “embed javascript” in markdown – Google Search.

–jeroen

Posted in Bookmarklet, Development, JavaScript/ECMAScript, Power User, Scripting, Software Development, Web Browsers | Leave a Comment »

JavaScript bookmarklet to replace part of the archive.li fixing: not possible 

Posted by jpluimers on 2023/05/31

Quite often while saving a URL in the WayBack Machine, the response often is headed “Sorry” with non-descriptive “Job failed”. In the background however, at least half of th…

Related: JavaScript bookmarklet to replace part of the WayBack machine URL

For instance, a while ago for instance http://archive.fo/search/?q=nu.nl, https://archive.fo/search/?q=nu.nl and similar URLs redirected to https://archive.li/search/?q=nu.nl, which in turn redirected to itself:

This page isn’t working

archive.li redirected you too many times.

ERR_TOO_MANY_REDIRECTS

This isn’t a cookie thing as it happens in an anonymous window on several browsers as well. Most redirect checkers return a 429, as Archive Today has quite strict rate limiting:

I tried these bookmarklets to go to a good archive.is link from the above replacing http://archive.fo/search/?q=nu.nlhttps://archive.fo/search/?q=nu.nl, http://archive.li/search/?q=nu.nl and https://archive.li/search/?q=nu.nl with https://archive.is/search/?q=nu.nl (with the same above bolded parts):

javascript:(function() {window.location=window.location.toString().replace(/^http.?:\/\/archive\.[is|li]\//,'https://archive.is/');})()

It can even be simpler (but maybe not fully conformant to specs):

javascript:location=location.href.replace(/^http.?:\/\/archive\.[is|li]\//,'https://archive.is/')

These both fail!

Even a simple bookmarklet like this fails too:

javascript:alert('hello world!');

It took me a bit of thinking to figure out why, but then figured out that any JavaScript requires a page context to run, and when no page is displayed, there is no context to run on.

And indeed:

–jeroen

Posted in Bookmarklet, Development, JavaScript/ECMAScript, Power User, Scripting, Software Development, Web Browsers | Leave a Comment »

JavaScript bookmarklet to replace part of the WayBack machine URL

Posted by jpluimers on 2023/05/23

Quite often while saving a URL in the WayBack Machine, the response often is headed “Sorry” with non-descriptive “Job failed”.

In the background however, at least half of those times the job actually succeeded.

Some periodes that success rate was way lower as the archival job didn’t start with a GET request. The workaround was to use a POST request, see I want to check out how to do POST requests using bookmarklets in order to save URLs to the WayBack machine and [Archive] Jeroen Wiert Pluimers on Twitter: “Does anyone why the @waybackmachine has a lot of job failed and 404 errors over the last few days? … and … just returned a 404; most of my archivals the last few days failed or had to be retried at least half a dozen times to succeed. …” / Twitter

The error message in both “Job failed” cases is the same, so it makes sense to differ between the first case (job started and complete, but web interface failed to get that) and the latter (job didn’t even start) by doing the below URL replacement with a bookmarklet:

Read the rest of this entry »

Posted in Bookmarklet, Development, JavaScript/ECMAScript, Power User, Scripting, Software Development, Web Browsers | Leave a Comment »

Windows 10 and 11: installing WSL2 does not require winget, Chocolatey or Scoop

Posted by jpluimers on 2023/05/18

After using Chocolatey for a long time and writing about it, I have written a few articles on other Windows package managers like winget and Scoop.

Part of the reason was that I wanted to install new systems in a semi-automatic way including WSL2 (Windows Subsystem for Linux 2).

As I have spent quite some time getting treated against metastasised rectum cancer, I missed part of the evolvement of WSL into WSL2 and of the winget evolvement.

The good news is that this simplified the scripted installation of WSL2 a lot, as over time, this got very easy, as confirmed in these posts/messages I found via [Wayback/Archive] winget wsl2 – Google Search:

I even found back this was announced when I was still in hospital: during the Build 2020 conference. A summary is at [Wayback/Archive] The Windows Subsystem for Linux BUILD 2020 Summary – Windows Command Line describing the introduction of wsl.exe --install and that it defaults to install WSL 2 as back-then already most Windows Insider build users using WSL had switched from WSL 1 to WSL 2.

Back to installing

Yesterday, in  Windows “equivalents” for bash backticks in cmd and PowerShell, I showed how to get the wsl.exe information:

C:\temp>PowerShell -Command "SigCheck "$((Get-Command -CommandType Application wsl).Path)""

Sigcheck v2.82 - File version and signature viewer
Copyright (C) 2004-2021 Mark Russinovich
Sysinternals - www.sysinternals.com

c:\windows\system32\wsl.exe:
        Verified:       Signed
        Signing date:   09:24 15/10/2021
        Publisher:      Microsoft Windows
        Company:        Microsoft Corporation
        Description:    Microsoft Windows Subsystem for Linux Launcher
        Product:        Microsoft« Windows« Operating System
        Prod version:   10.0.19041.1320
        File version:   10.0.19041.1320 (WinBuild.160101.0800)
        MachineType:    64-bit

This was on one of my Windows 10 systems with version 21H2.

The installation progress was as follows and took ome 3 minutes on a 50 Mibit/s fiber connection:

C:\temp>wsl.exe --install
Installing: Virtual Machine Platform
Virtual Machine Platform has been installed.
Installing: Windows Subsystem for Linux
Windows Subsystem for Linux has been installed.
Downloading: WSL Kernel
Installing: WSL Kernel
WSL Kernel has been installed.
Downloading: Ubuntu
The requested operation is successful. Changes will not be effective until the system is rebooted.

Time to play around (:

–jeroen

Posted in Batch-Files, Chocolatey, Development, Power User, Scoop, Scripting, Software Development, Windows, Windows Development, winget, WSL Windows Subsystem for Linux | Leave a Comment »

Windows “equivalents” for bash backticks in cmd and PowerShell

Posted by jpluimers on 2023/05/17

A while ago, I needed the file information of wsl.exe on one of my Windows systems.

On Linux, I would do something like file `which bash` where file will give the file details and which gets you the full path to bash.

The file equivalent on Windows for me is [Wayback/Archive] Sigcheck – Windows Sysinternals | Microsoft Docs, which is part of [Wayback/Archive] File and Disk Utilities – Windows Sysinternals | Microsoft Docs.

The which equivalent on Windows for me is [Wayback/Archive] where | Microsoft Docs.

Read the rest of this entry »

Posted in bash, Batch-Files, CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »

 
%d bloggers like this: