Skip to content

Instantly share code, notes, and snippets.

View aih's full-sized avatar

Ari Hershowitz aih

View GitHub Profile
@aih
aih / mac-docker.adoc
Created July 9, 2021 06:36
Using docker on MacOs
docker-machine start
eval "$(docker-machine env default)
@aih
aih / CSS for XML.md
Last active December 23, 2020 18:31
How to add styling (CSS) to an XML document

XML in the browser

Browsers generally work with HTML or the XML compatible variant, XHTML. However, they can also support XML, with some caveats. Xcential makes use of this in the LegisPro editor, to display and edit XML directly. We also use it to render XML in the browser with CSS, avoiding costly transformations to HTML.

To style XML, you need to add links to stylesheets (embedded styles may be supported, but not explicitly by the XML specification): https://www.w3.org/Style/styling-XML.en.html

For example, the attached bill.xml is styled with two css files. Place them in the same directory as bill.xml and open bill.xml in a browser. Generally, Firefox works best for this.

# Notes on converting GDoc to Asciidoctor
## GDoc to AsciiDoctor using Java + Google APIs
This method is described here as experimental. I did not try it: https://github.com/maxandersen/gdoc2adoc
## GDoc to AsciiDoctor script
This method uses a Google Apps script, which adds a menu to your Google Docs. The script and instructions are here:
https://github.com/maxandersen/gdoc2adoc
@aih
aih / process-bills.js
Created August 26, 2020 17:48
NodeJS script to process bills
#!/usr/bin/env node
var argv = require('yargs')
.usage('Usage: $0 <command> [options]')
.command('convert', 'Convert bills (e.g. with XSLT)')
.example('$0 convert -a', 'Convert all bills for the current congress')
.example('$0 convert -b 116hr200', 'Convert bills for 116hr200enr')
.example('$0 convert -b 116hr200 116hr144', 'Convert bills for 116hr200enr and 116hr144')
.option('a', {
description: 'All bills for one congress (defaults to current congress)',
alias: 'all'
@aih
aih / getRandomStrings.py
Last active June 8, 2020 23:27
Generate random strings in Python
import random
import string
myletters = string.ascii_letters + '!@#$%^&*' + '0123456789'
def randString(stringLength):
return ''.join(random.choice(myletters) for i in range(stringLength))
def getNRandStrings(n, m):
return [randString(n) for item in range(m)]
@aih
aih / CSSStringToBlobToFile
Created May 19, 2020 23:39
Convert string to blob and blob to file
// String to Blob
// https://stackoverflow.com/q/23024460/628748
const cssString = "selector{},...";
const cssBlob = new Blob([cssString], {
type: 'text/plain'
});
// Blob to File
// https://stackoverflow.com/a/48750233/628748
cssBlob.lastModifiedDate = new Date();
@aih
aih / downloadusc.py
Created December 5, 2019 16:34
Script to download release-points of the United States Code
#!python3
# -*- coding: utf-8 -*-
'Scrape USC release points'
# Sample release point link: https://uscode.house.gov/download/releasepoints/us/pl/115/239not232/usc-rp@115-239not232.htm
# TODO download *all* of the first release point (to createa baseline)
# TODO add current release point, linked from https://uscode.house.gov/download/download.shtml,
# e.g. https://uscode.house.gov/download/releasepoints/us/pl/116/65/xml_uscAll@116-65.zip
@aih
aih / gist:47fd080d6bfaab71e6e9d112dccf0104
Last active December 4, 2019 19:41
Nginx configuration for House-Posey2-UI
upstream nodeservice {
server 127.0.0.1:8091;
}
server {
listen 4200 default_server;
listen [::]:4200 default_server;
server_name localhost;
# Load configuration files for the default server block.
@aih
aih / upload-formdata.js
Created October 22, 2019 18:58
Sample upload using formdata element
// Uses the alertify library for notifications; any notification mechanism can be substituted
// The file to upload must be in an `input` element with @id = constants.DOC_UPLOAD_ID
// The name of the file is in uploadDocName, which is set from user input
let docUpload = function (uploadDocName) {
if(!uploadDocName){
alertify.error('Document name is required');
return
}
if(!validateDocName(uploadDocName)){
@aih
aih / setAttribute.js
Created September 6, 2019 20:12
Set attribute for styling
//document.querySelectorAll('[amendment]').setAttribute('isclassified', false);
document.querySelectorAll('[amendment]').forEach(item => item.removeAttribute('activeamendment'));
//THEN
//document.querySelectorAll('[amendment="selectedamendmentid"]').forEach(item => setAttribute('activeamendment', true));
document.querySelectorAll('[amendment="HB819FDEA29674204ABD2698D5DEED62F"]').setAttribute('activeamendment', true);