Skip to content

Commit

Permalink
programming can be fun again
Browse files Browse the repository at this point in the history
  • Loading branch information
hparra committed May 14, 2023
1 parent 8cc1aeb commit e612041
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 2 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# HGPA

1982 -

- [notes](notes/README.md)
- [journal](journal/README.md)
65 changes: 65 additions & 0 deletions notes/bookmarklets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# bookmarklets

these things have been around for a long time!
javascript has changed too!

## copy a markdown link

```js
javascript:(async function copyMarkdownLink(s) {
/* copy a markdown link with page title and href to the clipboard */
const mdLink = `[${document.title}](${window.location.href})`;
const type = 'text/plain';
const blob = new Blob([mdLink], { type });
const data = [new ClipboardItem({ [type]: blob })];
await navigator.clipboard.write(data);
})();
```

## copy a markdown citation

i would like to create a citation using a format that i like.

i can use page href, title and description, but many pages have additional data.
some pages have JSON-LD tags and many more have open-graph meta tags.

```js
javascript:(async function copyMarkdownCitation(s) {
/* copy a markdown link and page citation to the clipboard */
function meta(q) {
const el = document.querySelector(`meta${q}`);
return el && el.content || null;
}
const c = {
title: meta('[property="og:title"]') || document.title,
href: meta('[property="og:url"]') || window.location.href,
author: meta('[name="author"]'),
siteName: meta('[property="og:site_name"]') || window.location.hostname,
description: meta('[name="description"]'),
};
switch (window.location.hostname) {
case 'en.wikipedia.org':
c.title = document.title.split(' - ')[0];
c.author = 'Wikipedia';
break;
case 'developer.mozilla.org':
c.title = document.title.split(' | ')[0];
c.author = 'MDN';
default:
break;
}
const mdLink = `[${c.title}](${c.href}). ${c.author}. ${c.siteName}.`;
const type = 'text/plain';
const blob = new Blob([mdLink], { type });
const data = [new ClipboardItem({ [type]: blob })];
await navigator.clipboard.write(data);
})();
```

## references

[Bookmarklet](https://en.wikipedia.org/wiki/Bookmarklet). Wikipedia. en.wikipedia.org.

[Bookmarklets are Dead…](https://medium.com/making-instapaper/bookmarklets-are-dead-d470d4bbb626). Brian Donohue. Medium.

[Clipboard: write() method - Web APIs](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/write). MDN. developer.mozilla.org.
2 changes: 2 additions & 0 deletions notes/jekyll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# jekyll

4 changes: 4 additions & 0 deletions notes/postmortem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# postmortem

## references

26 changes: 26 additions & 0 deletions notes/snes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Super Nintendo Entertainment System (SNES)

an absolute joy.

## favorites

- Actraiser
- Chrono Trigger
- Donkey Kong Country
- Final Fantasy III (VI)
- F-Zero
- Mario Paint
- NBA Jam
- The Legend of the Mystical Ninja
- The Legend of Zelda: A Link to the Past
- StarFox
- Street Fighter II
- Super Bomberman
- Super Mario Kart
- Super Mario RPG
- Super Mario World
- UN Squadron

## references

[Random: Shinji Mikami Had To Ban The Resident Evil Devs From Playing Tetris Attack](https://www.nintendolife.com/news/2019/10/random_shinji_mikami_had_to_ban_the_resident_evil_devs_from_playing_tetris_attack). lol.

0 comments on commit e612041

Please sign in to comment.