commit 8e848728be5219f20a1be619290668b049084fe0
Author: Oshgnacknak <osh@oshgnacknak.de>
Date: Sun, 28 Mar 2021 17:36:11 +0200
Initial commit
Diffstat:
9 files changed, 163 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
@@ -0,0 +1,45 @@
+# FOP Macros
+
+Collection of macros to to help during the FOP exam.
+If any macro breaks your typing,
+press and release `ctrl + shift + alt` to fix those keys.
+
+## Getting started
+
+1. Install [sxhkd](https://wiki.archlinux.org/index.php/Sxhkd)
+and [xdotool](https://wiki.archlinux.org/index.php/Xdotool#Automation).
+
+1. Run `sxhkd -c macros.sxhkd` in the background.
+
+## Macros
+
+### aspekts of oop
+`ctrl + shift + alt + a`:
+[Four buzz words](https://www.indeed.com/career-advice/career-development/what-is-object-oriented-programming)
+professors love to hear.
+
+### filter map
+`ctrl + shift + alt + f + m`:
+Racket implementation of
+[filter map](https://docs.racket-lang.org/reference/pairs.html?q=map#%28def._%28%28lib._racket%2Flist..rkt%29._filter-map%29%29).
+You might need to inline `f` (the mapper) and `p` (the predicate).
+Remove `f` to get `filter` or `p` to get `map`.
+
+### interface
+`ctrl + shift + alt + i`:
+Standard [java interface](https://www.w3schools.com/java/java_interface.asp)
+with five [methods](https://www.w3schools.com/java/java_methods.asp).
+
+### class
+`ctrl + shift + alt + c`:
+Standard [java class](https://www.w3schools.com/java/java_classes.asp)
+with a lot of boilerplate.
+
+### exception
+`ctrl + shift + alt + e`:
+Standard [java exception](https://www.tutorialspoint.com/java/java_exceptions.htm)
+with a costume [constructor](https://www.w3schools.com/java/java_constructors.asp).
+
+### listitemmethod
+`ctrl + shift + alt + l`:
+A Method to work with two `ListItem<T>` "pointers" without recursion.
diff --git a/macros.sxhkd b/macros.sxhkd
@@ -0,0 +1,17 @@
+ctrl + shift + alt + a
+ ./retype aspekts_of_oop
+
+ctrl + shift + alt + f + m
+ ./retype filtermap
+
+ctrl + shift + alt + i
+ ./retype interface
+
+ctrl + shift + alt + c
+ ./retype class
+
+ctrl + shift + alt + e
+ ./retype exception
+
+ctrl + shift + alt + l
+ ./retype listitemmethod
diff --git a/macros/aspekts_of_oop b/macros/aspekts_of_oop
@@ -0,0 +1,4 @@
+- Kapselung
+- Abstraktion
+- Vererbung
+- Polymorphie
diff --git a/macros/class b/macros/class
@@ -0,0 +1,32 @@
+public abstract class C<T1> extends D implements I<T1> {
+
+ protected List<T1> l1;
+ protected List<T1> l2;
+ protected List<T1> l3;
+
+ public C(int i1, int i2, int i3, List<T1> l1, List<T1> l2, List<T1> l3) {
+ super(i1, i2, i3);
+ this.l1 = l1;
+ this.l2 = l2;
+ this.l3 = l3;
+ }
+
+ @Override
+ public <T2> T1 m1(T1 t1, T2 t2) throws Exception {
+ return null;
+ }
+
+ @Override
+ public <T2> T1 m2(T1 t1, T2 t2) throws Exception {
+ return null;
+ }
+
+ public static <T> T m2(T t) throws Exception {
+ return null;
+ }
+
+
+ public abstract <T> T m6(T t) throws Exception;
+ public abstract <T> T m7(T t) throws Exception;
+ public abstract <T> T m8(T t) throws Exception;
+}
diff --git a/macros/exception b/macros/exception
@@ -0,0 +1,5 @@
+public class MyException extends Exception {
+ public MyException(int n) {
+ super(n+"!");
+ }
+}
diff --git a/macros/filtermap b/macros/filtermap
@@ -0,0 +1,5 @@
+(define (filtermap p f lst)
+ (cond
+ [(empty? lst) empty]
+ [(p (first lst)) (cons (f (first lst)) (filtermap p f (rest lst)))]
+ [else (filtermap p f (rest lst))]))
diff --git a/macros/interface b/macros/interface
@@ -0,0 +1,7 @@
+public interface I <T1> extends List<T1> {
+ <T2> T1 m1(T1 t1, T2 t2) throws Exception;
+ <T2> T1 m2(T1 t1, T2 t2) throws Exception;
+ <T2> T1 m3(T1 t1, T2 t2) throws Exception;
+ <T2> T1 m4(T1 t1, T2 t2) throws Exception;
+ <T2> T1 m5(T1 t1, T2 t2) throws Exception;
+}
diff --git a/macros/listitemmethod b/macros/listitemmethod
@@ -0,0 +1,25 @@
+public static <T> ListItem<T> m(ListItem<T> l1, ListItem<T> l2) {
+ while (l1 != null && l2 != null) {
+ l1 = l1.next;
+ l2 = l2.next;
+ }
+
+ ListItem<T> head = null;
+ ListItem<T> tail = null;
+
+ while (l1 != null) {
+ if (head == null) {
+ head = tail = new ListItem<>();
+ }
+
+ tail.key = l1.key;
+
+ if (l1.next != null) {
+ tail.next = new ListItem<>();
+ tail = tail.next;
+ }
+ l1 = l1.next;
+ }
+
+ return head;
+}
diff --git a/retype b/retype
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+DELAY="40"
+LINE_DELAY="0.1"
+
+if [[ $# == 0 ]]; then
+ echo "Usage: $0 <name-of-macro>"
+ exit 1
+fi
+
+file="./macros/$1"
+
+setxkbmap
+while IFS='' read -r line; do
+ xdotool type \
+ --clearmodifiers \
+ --delay $DELAY \
+ "$line"
+ xdotool key \
+ --clearmodifiers \
+ --delay $DELAY \
+ Return
+done < $file