Skip to content

Instantly share code, notes, and snippets.

@bion
bion / gist:3c98eeeb8015c7f597870c61da657b2b
Last active December 27, 2023 21:06
CiviForm front end questionnaire answers

[Bion] Copied from https://github.com/bradfrost/frontend-guidelines-questionnaire/

Frontend Guidelines Questionnaire

A one-page questionnaire to help your team establish effective frontend guidelines, so that you can write consistent & cohesive code together.

HTML

HTML Principles

  • What are some general principles your team should follow when writing HTML? (for example, authoring semantic HTML5 markup, accessibility, etc. See these resources for inspiration)

[Bion] We strive to use semantic markup, preferring browser default behavior over custom implementations when possible.

@bion
bion / html-to-j2html.py
Last active November 29, 2023 20:19
HTML TO J2HTML WHEN WILL THE MADNESS STOP?
#! /usr/bin/env python3
from html.parser import HTMLParser
import io
import sys
class J2HtmlGenerator(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
@bion
bion / daw.sh
Last active February 25, 2024 06:23
Linux audio work environment - supercollider in emacs routed to REAPER via jackd
#! /usr/bin/env bash
set -e
set -m
set +x
output_device="PCH"
if cat /proc/asound/cards | grep -q Scarlett; then
output_device="USB"
@bion
bion / sc_demo.scd
Last active September 7, 2021 06:08
supercollider demo
// start scsynth, the server
// s is bound to the default server when the sclang starts
s.boot;
// define a simple synthesizer definition and send it to the server
SynthDef('simpleSine', {
Out.ar(0, SinOsc.ar(440, 0, -16.dbamp));
}).send(s);
// create a synth using that definition
@bion
bion / extract-text
Last active December 23, 2021 09:20
OCR latest screenshot
#! /usr/bin/env bash
set -euf -o pipefail
input_file="$1"
temp_file=$(mktemp)
convert "$input_file" "$temp_file.tif"
tesseract -l eng "$temp_file.tif" "$temp_file" &> /dev/null
@bion
bion / ThreadingDemo.java
Last active February 24, 2021 21:19
Threading in Play
// See https://www.playframework.com/documentation/2.8.x/ThreadPools for more info
//
// Applicant-accessible code paths should never block on network I/O.
// If you use CompleteableFuture#join() be very careful it is not on an applicant-accessible code path.
class ThreadingDemo {
private final HttpExecutionContext httpExecutionContext;
private final DatabaseExecutionContext databaseExecutionContext;
private final DemoService demoService;
@bion
bion / ApplicantProgramBlocksController.java
Last active February 23, 2021 21:26
applicant system controller sketches
class ApplicantProgramBlocksController {
// GET /applicants/22/programs/12/block/21/edit
public CompletionStage<Response> edit(long applicantId, long programId, long blockId) {
return applicantService.getReadOnlyApplicantService(applicantId, programId)
.then((ReadOnlyApplicantService roApplicantService) -> {
ImmutableList<Block> blockList = roApplicantService.getCurrentBlockList();
return ok(views.html.blockForm.render(blockList, blockId));
});
{
type: "user-defined",
name: "employment"
repeated: true,
props: {
employerName: "string"
}
}
@bion
bion / file.java
Created January 27, 2021 19:59
JsonPath approach
// <input name="applicant.employments[2].employerName" type="text" />
// employer.name
// employer.address.zip
// employer.address.street
class Update {
UpdatePath path;
@bion
bion / 01_classes_and_interfaces.java
Last active January 27, 2021 00:00
Domain model design sketch -- ObjectMapper approach
@Entity
class Applicant extends Model {
@Id
Long id;
@DbJsonB