Skip to content

Instantly share code, notes, and snippets.

View javajosh's full-sized avatar

javajosh javajosh

View GitHub Profile
@javajosh
javajosh / script-template.sh
Created December 15, 2020 23:16 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@javajosh
javajosh / lightweight-site-coherence.md
Last active July 5, 2020 02:33
A lightweight way to make same-site resources coherent without using templates or a front-end build

What if each webpage in a hierarchy loaded every specially named javascript file in every directory up to root? This would be a relatively lightweight way to impose what I think of as "proximity coherence" on a collection of resources. That is, each resource would not just be loaded as is, but rather load up whatever its ancestors wanted to add, such as a navigation or site identification. It is neatly recursive, too and would nicely support deep eneterprise-style hierarchies of content, including giving each level a chance to modify the behavior that preceded it. Meaning the root script, executing last, having the last word, so to speak, would be the most powerful. I've never seen this done, but it would be simple to do in JavaScript.

Probably the hardest part of the code would be breaking up the URL path into an array of subdirectories, which for a prototype could be as simple as const dirs = location.path.split('/'); while(dirs.length) include(dirs.pop(), 'index.js')

Gov -

Happy 4th. Thinking about the us gov tonight, and how it would be nice to have a map that just gives you contact info for any congressional district, including senators, with your mouse. Bostock already did most of the hard work, including helpful information about how to update this information with each change of congress, which happens every 2 years.

A few things are missing, of course, first is a contact database for congress, which is at least partially attainable on the Elected Officials Site - it's not clear if there's a downloadable, low-entropy representation but it looks like the data is pretty regular, and not hard to scrape, and it's not even too large to scrape by hand every 2 years!

Another thing that is missing is zoomability: there is an enormous range of sizes in US congressional districts, where states like Montana have just one for the whole state, and more populated states can have upwards of 50,

@javajosh
javajosh / README.md
Last active March 14, 2019 19:53
An experiment with

This is a SCRIPT-8 cassette. This is a revision. This is another revision.

@javajosh
javajosh / README.md
Created January 26, 2019 09:15
SCRIPT-8
@javajosh
javajosh / README.md
Created January 26, 2019 09:15
SCRIPT-8
@javajosh
javajosh / background.js
Last active February 26, 2018 09:05
Chrome extension that fails to adjust HTTP status line code.
let count = 0;
function listener1(details){
return {cancel: true};
}
function listener2(details){
console.log(count++, details);
if (!details) return;
for (let i = 0; i < details.responseHeaders.length; i++){
if (details.responseHeaders[i].name === 'status'){
@javajosh
javajosh / chrome_ideas.txt
Created October 28, 2017 23:36
Ideas for Chrome
1. Add a common code cache. Save parsed js libraries locally; also other resources.
Detail: Chrome should detect common subresource requests and satisfy them with local copies. This puts (good) pressure on devs to
*stop bundling code*. I'd like to see a special page in chrome (e.g. chrome://codecache) that lists out all the
subresources I currently have. Ideally, the JS resources would be stored in a clonable pre-parsed state, and optionally
make them immutable. The same could be applied to CSS, images, and fonts. Over time my Chrome instance would accrete a
list of resources, and get faster and faster. Combine with subresource integrity, or implement more losely (does it really
matter what version of jQuery this site needs? Probably not.) Another nice feature of this is we'd be able to use the
unminified code without a performance hit improving idea- and technique-sharing. The tradeoff is risk of breakage.
This can be prototyped with a browser extension.

First boot Accept defaults. Sign-in to wifi Don't give apple ID (don't want itunes or icloud)

Dock autohide, move left, remove most things. Privacy Turn on firewall, Turn off location services, turn off diagnostics to apple, turn off crash data to devs Display

@javajosh
javajosh / pom.xml
Created October 27, 2017 18:12
A nice starter POM.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.javajosh</groupId>
<artifactId>Hello</artifactId>
<version>1.0-SNAPSHOT</version>
<build>