Skip to content

Instantly share code, notes, and snippets.

View atroia's full-sized avatar
🎧

Aaron Troia atroia

🎧
  • Idaho
View GitHub Profile
@cmod
cmod / html2md.md
Last active April 6, 2025 16:57
Convert HTML (in clipboard) to Markdown (in clipboard) Alfred Workflow

Simple Alfred workflow using Node to convert rich-text HTML (i.e., just select and copy from a website) in your clipbaord to Markdown, replacing the HTML in the clipboard.

Requirements

  • Node.js
    • brew install node in macOS terminal
    • turndown package (npm install turndown in terminal)
  • Alfred launcher

Workflow Configuration

@gregoriopellegrino
gregoriopellegrino / get_langs_in_html_document.js
Last active August 14, 2019 00:03
Very simple script in jQuery to find all the languages present in an HTML document. Useful for controlling the accessibility of documents. Improvements are welcome. #a11y Made to run from the browser development console
// main lang
if ($("html").get(0).hasAttribute("lang")) {
var main_lang = $("html").attr("lang");
} else {
var main_lang = $("body").attr("lang");
}
console.log("Main language is "+main_lang);
// children lang
var langs = [];
@joonaspaakko
joonaspaakko / Apply Master To Empty Pages.jsx
Last active August 3, 2023 21:21
Indesign script that applies a master page to all empty pages in the document.
// https://gist.github.com/joonaspaakko/f16b47be887a2058cd0c0ac6e7ab0343
// The script doesn't check for page items inside the current master.
// That means the current master could be filled with all kinds of graphics and this script considers it an empty page.
var master;
if (app.documents.length > 0) init();
function init() {
@JayPanoz
JayPanoz / index.js
Last active June 5, 2019 16:23
A proof of concept script to append aria doc roles based on epub:type
// This is now its own package @ https://github.com/rodebert/epubtype-to-aria
// Please check Rodebert’s repo for a better and more up-to-date version
"use strict";
// Get all the elements with epub:type
// Since querySelectorAll can’t be used with XHTML attributes,
// we create an array in which we’ll push elements with an epub:type attribute
var epubTypes = [];
@JayPanoz
JayPanoz / coreprocessor.js
Last active April 21, 2018 10:23
What KP does behind the scenes for KFX
/*
* Copyright (c) 2015 Amazon.com. All rights reserved.
KP 3.21.0
*/
var fa = {
SUCCESS: 0,
HTML_LOAD_FAILURE: 1,
INJECTION_FAILURE: 2,
JAVASCRIPT_FAILURE: 3,
INTERNAL_FAILURE: 4,
@So-Cool
So-Cool / extractor.py
Last active January 23, 2024 19:53
Prettify ugly MS Word HTML
import os
import sys
from bs4 import BeautifulSoup
if len(sys.argv) != 3:
sys.exit("First argument is HTML second is an output directory.")
with open(sys.argv[1], "r") as html:
soup = BeautifulSoup(html.read(), "html.parser")
@NickBarreto
NickBarreto / iBooks popups which degrade nicely in other devices
Last active September 3, 2024 10:37
How to create popup footnotes in iBooks which degrade well for other EPUB3 readers
The only requirements for popup footnotes in iBooks are:
* Ebook has to be an EPUB3
* epub:type "noteref" and "footnote"
So you can link to a totally separate document, as you normally would for endnotes,
but include the attributes so the <a> link behaves differently in iBooks, instead triggering the popup.
Original reference link would look something like this (in a file called ch001.html):
<a epub:type="noteref" href="footnote.html#note1">1</a></div>
@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #