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
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 = evt.detail.elt.name;
@corlaez
corlaez / README.md
Last active June 6, 2023 03:12
Kotlin Webjars Locator Ktor Gradle
View README.md

This is how I like to use webjars in kotlin.

build.gradle.kts dependencies:

dependencies {
    // webjars
    implementation("org.webjars:webjars-locator:0.46")
    implementation("org.webjars.npm:htmx.org:1.9.2")
}
@corlaez
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
corlaez / README.md
Last active November 3, 2022 16:14
Violin Students Report
View README.md

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
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
corlaez / LICENSE
Last active August 28, 2022 03:23
Modest Variation (Markdown css)
View LICENSE
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
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
corlaez / README.md
Last active March 20, 2022 21:08
Violin Strings guide
View README.md

String Identification

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

image

@corlaez
corlaez / 1-gavotte-f-j-gossec.md
Last active August 7, 2022 21:38
Book1: Gavotte by F J Gossec
View 1-gavotte-f-j-gossec.md

Gavotte

Allegretto - F. J. Gossec

(G Major)

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

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