I hereby claim:
- I am ggalmazor on github.
- I am ggalmazor (https://keybase.io/ggalmazor) on keybase.
- I have a public key ASAbZuXpyLdy8y8QZR-YKb2L5yVNgcFhlzkWN3dgyNr8MAo
To claim this, I am signing this object:
import { Octokit } from '@octokit/rest'; | |
import { getTime, isBefore, parseISO } from 'date-fns'; | |
const octokit = new Octokit({ auth: 'token foobar' }); | |
const durationSeconds = (a, b) => Math.round((getTime(parseISO(b)) - getTime(parseISO(a))) / 1000); | |
const isBeforeCutoff = (cutoffISO8601) => { | |
const cutoff = parseISO(cutoffISO8601); | |
return (deployment) => isBefore(parseISO(deployment.created_at), cutoff); | |
}; |
# frozen_string_literal: true | |
require 'gnuplot' | |
require 'narray' | |
# Function to calculate the perpendicular distance from a point to a line | |
def perpendicular_distance_pip(x0, y0, x1, y1, xp, yp) | |
num = ((y1 - y0) * xp - (x1 - x0) * yp + x1 * y0 - y1 * x0).abs | |
denom = Math.sqrt((y1 - y0) ** 2 + (x1 - x0) ** 2) | |
num / denom |
#!/bin/zsh | |
BRANCH_NAME=$(git branch | grep '*' | sed 's/* //') | |
if [[ $BRANCH_NAME != *"no branch"* ]] | |
then | |
FILENAMES=$(git diff --staged --name-only --diff-filter=AM | grep -e "\.rb$" -e "\.rake$") | |
if [[ -z "${FILENAMES// }" ]] | |
then | |
echo "Skipping Rubocop pre-commit hook" |
void read_frequency() { | |
if (Serial.available() <= 0) | |
return; | |
String description = read_serial_message(0xFD); | |
if (!is_valid(description)) | |
return; | |
return parse_frequency(description); |
I hereby claim:
To claim this, I am signing this object:
I spend most of my working day helping to maintain and evolve the awesome OpenDataKit tool kit, which includes ODK Briefcase, a Java desktop application (Swing) that takes care of pulling, pushing and exporting forms.
Before continuing, I feel like I should give a disclaimer. It's a long post that's served me to put my thoughts together and fix in my head what I've learned. You could read on and miss some obvious and much simpler solution to some problem. If that happens, please, please, write a comment! I'm not trying to write any foundational text. I'm just a guy figuring out how to do parallel jobs in Java, and I'm probably wrong.
Briefcase interacts with servers that store blank forms and answered form submissions using an HTTP API to download them to a user's computer for post-processing.
public class Job<T> { | |
private final JobAwareSupplier<T> block; | |
private Job(JobAwareSupplier<T> block) { | |
this.block = block; | |
} | |
public static <U> Job<U> supply(JobAwareSupplier<U> supplier) { | |
return new Job<>(supplier); | |
} |
public ExecutorService pull(List<FormStatus> forms) { | |
ExecutorService executor = new ForkJoinPool( | |
commonPool().getParallelism(), | |
commonPool().getFactory(), | |
this::handleError, | |
commonPool().getAsyncMode() | |
); | |
forms.stream() | |
.map(form -> pullOne(form, executor)) |
public class ExportPanelForm { | |
private static final String EXPORTING = "Exporting"; | |
private static final String DOT = "."; | |
private JLabel exportingLabel; | |
public void updateExportingLabel() { | |
String newText = cycle(exportingLabel.getText(), 19); | |
exportingLabel.setText(newText); | |
} |
public class ExportPanelForm { | |
private static final String EXPORTING = "Exporting"; | |
private static final String DOT = "."; | |
private JLabel exportingLabel; | |
public void updateExportingLabel() { | |
String text = exportingLabel.getText(); | |
if (text.equals(EXPORTING + DOT + DOT + DOT + DOT + DOT + DOT + DOT + DOT + DOT + DOT)) { | |
text = EXPORTING + DOT; | |
} else { |