Skip to content

Instantly share code, notes, and snippets.

View cvanloo's full-sized avatar
💢
Programming: You're doing it completely wrong.

Colin van Loo cvanloo

💢
Programming: You're doing it completely wrong.
View GitHub Profile
func pointOfNoReturn(n int) (r int) {
defer func() {
e := recover()
r = e + 1
}()
panic(n - 1)
}
@cvanloo
cvanloo / expr->html.clj
Created April 23, 2024 13:15
Convert S-Expression to HTML
(declare expr->html write-props write-tags)
(defn write-props
[props]
(reduce
(fn [out [k v]]
(str out " " (name k) "=" \" (name v) \"))
""
props))
#include <stdio.h>
#include <assert.h>
#define NPARTS 4
#define IS_ODD(x) ((x) % 2)
#define IS_EVEN(x) (((x) + 1) % 2)
int main(void) {
int part_widths[NPARTS] = {0};
@cvanloo
cvanloo / rsa.clj
Last active November 6, 2023 14:39
RSA Verschlüsselung
;; Serie 7, Aufgabe 4
(defn gcd [a b]
(cond
(zero? a) b
(zero? b) a
(> b a) (recur b a)
:else (recur b (mod a b))))
(defn coprime? [a b]
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <WinUser.h>
#include <random>
int main() {
int x {GetSystemMetrics(SM_XVIRTUALSCREEN)};
int y {GetSystemMetrics(SM_YVIRTUALSCREEN)};
int w {GetSystemMetrics(SM_CXVIRTUALSCREEN)};
int h {GetSystemMetrics(SM_CYVIRTUALSCREEN)};
@cvanloo
cvanloo / usb_hid_keys.h
Created May 26, 2023 13:21 — forked from MightyPork/usb_hid_keys.h
USB HID Keyboard scan codes
/**
* USB HID Keyboard scan codes as per USB spec 1.11
* plus some additional codes
*
* Created by MightyPork, 2016
* Public domain
*
* Adapted from:
* https://source.android.com/devices/input/keyboard-devices.html
*/