Skip to main content
tdro

Another wandering soul screaming into the void. If you are looking for my blog you are in the wrong place. The profile and header pictures are brought to you by cdd20.

tdro micro.thedroneely.com (edited) view Markdown Plaintext Embed Permalink Sep 28 2022 02:36 UTC 24 sec 72/50 words

Chrome --headless can dump the to the command line. Set a virtual time budget in [?] for the to settle down and then do stuff.

shell
Html() {
  chromium \
    --headless \
    --incognito \
    --dump-dom \
    --virtual-time-budget=999999 \
    "$1"
}

HtmlToText() {
  lynx -stdin -dump -nolist
}

This has “peculiar” uses. Fun fact: invoking the name of chromium around normal people confers alien–like status.

shell
Html 'https://www.youtube.com/' | HtmlToText
#gists
tdro

Another wandering soul screaming into the void. If you are looking for my blog you are in the wrong place. The profile and header pictures are brought to you by cdd20.

tdro micro.thedroneely.com view Markdown Plaintext Embed Permalink Sep 2 2022 11:13 UTC 16 sec 48/50 words
tdro

Another wandering soul screaming into the void. If you are looking for my blog you are in the wrong place. The profile and header pictures are brought to you by cdd20.

tdro micro.thedroneely.com (edited) view Markdown Plaintext Embed Permalink Aug 26 2022 22:20 UTC 47 sec 140/50 words
My puppeteer scripts now use deno

No more need for npm in my personal stack! spawnSync + which returns the local browser’s path.

javascript
import puppeteer from "https://deno.land/x/puppeteer@16.2.0/mod.ts";

const chrome = "firefox";   /* Browser Chrome: "firefox" | "chromium" | "google-chrome" | ... */
const product = "firefox";  /* Product Base:   "firefox" | "chrome" */

const { status, stdout, stderr } = Deno.spawnSync("which", {
  args: [ chrome, ],
});

const executablePath = new TextDecoder().decode(stdout).trim();

const browser = await puppeteer.launch({
  headless: false,
  executablePath: executablePath,
  product: product,
});

const page = await browser.newPage();
await page.setViewport({ width: 1024, height: 768, });

const sites = [ "example.com", ];

for (const site of sites) {
  await page.goto("http://" + site);
  await page.screenshot({ path: site + ".png" });
}

await browser.close();
Basic Boilerplate: Captures a picture of example.com (main.ts)
shell
deno run --allow-all --unstable main.ts
Deno Version: 1.23.0
#gists #webdev
tdro

Another wandering soul screaming into the void. If you are looking for my blog you are in the wrong place. The profile and header pictures are brought to you by cdd20.

tdro micro.thedroneely.com view Markdown Plaintext Embed Permalink Jul 6 2022 22:57 UTC 27 sec 80/50 words
Web servers can be spun up quickly on the command line but with gotchas. 

Take the innocent web server .

shell
php -S 127.0.0.1:8080

Best not to use PHP’s web server cli (even for PHP) because routes with a dot (.) are assumed to be static files. Use a real web server or superior cli web servers with minor gotchas.

shell
python -m http.server --bind 127.0.0.1 8080
busybox httpd -f -p 127.0.0.1:8080
ruby -run -e httpd . -p 8080
#gists #webdev

Authors

Gallery

Following (6)

Web Ring