Skip to content

Instantly share code, notes, and snippets.

View corlaez's full-sized avatar
WFH since January 2020

Armando Cordova corlaez

WFH since January 2020
View GitHub Profile
corlaez / checkboxFix.js
Last active June 10, 2023 08:44
htmx cookbook
View checkboxFix.js
// This is meant to be in a html head script tag
// checkboxes are very inconvenient in html and will serialize nothing when the checkbox is unchecked
// instead of using hx-vals and writting a bit of JSON each time you have a checkbox I decided to fix it globally:
window.onload = function() {
document.body.addEventListener('htmx:configRequest', function(evt) {
const isInput = evt.detail.elt.tagName == 'INPUT';
const isCheckbox = evt.detail.elt.type == 'checkbox';
const isNotChecked = evt.detail.elt.checked == false;
if(isInput && isCheckbox && isNotChecked) {
const name =;
corlaez /
Last active June 6, 2023 03:12
Kotlin Webjars Locator Ktor Gradle

This is how I like to use webjars in kotlin.

build.gradle.kts dependencies:

dependencies {
    // webjars
corlaez / main.kt
Last active June 2, 2023 20:40
Fast Inverse Square Root in Kotlin
View main.kt
import kotlin.math.pow
fun fastInverseSqrt(number: Float): Float {
val ieee754FloatBits = number.toBits() // evil floating point bit hack, avoided
val invSqrt = Float.fromBits(0x5f3759df - (floatsBits shr 1)) // what the fish
return invSqrt * (1.5F - (0.5F * number * invSqrt * invSqrt)) // Newton iteration
corlaez /
Last active November 3, 2022 16:14
Violin Students Report

Maya (Adult)

She has previously taken lessons and recently decided to take them again. Good tone but needs to readjust to the violin a gain more dexterity/confidence. For personal reasons she may also need to stop taking lessons for a while, so resources are being shared for independent practice.

Working on

  • Vibrato basics exercises
  • Bow exercise (keep straight looking to the mirror)
  • Left hand rithms (quintuplet, sextuplet and septuplet) using part of Miroslav Skorik's Spanish dance
  • G Scales
  • "The shadow of your smile"
corlaez / Main.kt
Last active August 31, 2022 13:32
Simple browser auto-reloader in Kotlin
View Main.kt
import org.eclipse.jetty.http.HttpStatus
import java.time.LocalDateTime
fun main(args: Array<String>) {
val arg = Args.valueOf(args[0])
val port = System.getenv("PORT") ?: "8080"
if (arg.isRegenerate()) {
val serverArg = getRequestArg(port)
with(EnvContext(serverArg, port, webPlugins)) {
generate()// Here I generate my static website
corlaez / LICENSE
Last active August 28, 2022 03:23
Modest Variation (Markdown css)
The MIT License (MIT)
Copyright (c) 2014-2015 John Otander
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
corlaez / main.kt
Created May 18, 2022 02:10
Self Study Flashcard CLI
View main.kt
val chapter1 = mapOf(
"2 + 2" to "4",
"0 + 2" to "2",
val chapters = chapter1// + chapter2 + chapter3
fun main() {
while (true) {
val shuffledQuestions = chapters.keys.shuffled()
corlaez /
Last active March 20, 2022 21:08
Violin Strings guide

String Identification

  • E is the thinnest string
  • A is the second thinnest string
  • D is the second thickest string
  • G is the thickest string


corlaez /
Last active August 7, 2022 21:38
Book1: Gavotte by F J Gossec


Allegretto - F. J. Gossec

(G Major)

| A3A4 A3A1 A2A3 A2A0 | D3 E12 D3 xx | A2A3 A2A0 A1A2 A1D3  | A0 A#23 D0 xx |
| A3A4 A3A1 A2A3 A2A0 | D3 E12 D3 xx | A1   D3D1 D3   D1G#3 | D0 A#23 D0 xx |
corlaez /
Last active October 18, 2023 23:39
Hexagonal Architecture and Modular Implementation

Hexagonal Architecture

Conceptualized by Alistair Cockburn. Also known as "Ports and Adapters".

In a nutshell:

Application Driver -> Primary Adapter -> Primary Port -> Use Case -> Secondary Port -> Secondary Adapter -> External System/Side Effect