Skip to content

Instantly share code, notes, and snippets.

@erictroebs
erictroebs / TestMenge.java
Last active June 24, 2021 16:11
ClassCastException when converting generic lists to arrays in Java
import java.util.Arrays;
import java.util.LinkedList;
public class TestMenge {
LinkedList<String> StringList = new LinkedList<>();
public String[] getElements() {
return (String[]) StringList.toArray();
}
@erictroebs
erictroebs / SetFontMonospaced.java
Last active June 21, 2021 17:48
comparison between default and monospaced font in Java Swing
import javax.swing.*;
import java.awt.*;
public class SetFontMonospaced {
public static final String TEXT = " A C G T\nA * - - -\nC - * - -\nG - - * -\nT - - - *";
public static void main(String[] args) {
for (int i = 1; i <= 2; i++) {
JFrame frame = new JFrame("Fenster " + i);
frame.setSize(640, 360);
@erictroebs
erictroebs / script.js
Last active November 24, 2020 14:44
extract moodle course participants by group name
$(".cell.c4") // select every table cell in fourth column (group)
.filter((k, e) => $(e).text() !== "Gruppe 2") // filter participants not in specified group
.parent().find(".c1") // select table cell in first column (name)
.filter((k, e) => $(e).text()) // filter rows with empty names
.map((k, e) => "rm -rf " + $(e).text().trim().replaceAll(" ", "\\ ") + "_*") // map to linux rm command
.toArray() // convert to javascript array
.reduce((a, v) => a + v + "\n", "") // reduce to single string
@erictroebs
erictroebs / Touch.cpp
Last active November 10, 2023 17:14
Arduino Micro (ATmega32U4) Ten Finger Touchscreen Example
#include "Touch.h"
#if defined(_USING_HID)
#define CONTACT_COUNT_MAXIMUM 10
#define REPORTID_TOUCH 0x04
#define LSB(v) ((v >> 8) & 0xff)
#define MSB(v) (v & 0xff)