Skip to content

Instantly share code, notes, and snippets.

View Odepax's full-sized avatar
:shipit:
Edit this user's status

Odepax

:shipit:
Edit this user's status
View GitHub Profile
@Odepax
Odepax / Remove-Git-Tag.txt
Created November 22, 2021 19:13
Remove Remote Git Tag
git tag -d "tag_name"
git push --delete origin "tag_name"
@Odepax
Odepax / CallerMemberName-works-on-fields.cs
Created September 21, 2021 20:10
CallerMemberName works on fields!
using System.Runtime.CompilerServices;
static class Program {
class Symbol {
public readonly string DebugName;
public Symbol([CallerMemberName] string? debugName = null) => DebugName = debugName ?? string.Empty;
}
static readonly Symbol TheSymbol = new(); // TheSymbol.DebugName is "TheSymbol"!
}
@Odepax
Odepax / go-dark.js
Last active May 13, 2021 21:47
Quick & dirty dark theme
((invertImages, invertCode, applyBlackBackground) => {
document.body.style.filter = "invert()"
document.body.style.background = applyBlackBackground ? "black" : "white"
Array.from(document.querySelectorAll("pre")).map(pre => pre.style.filter = invertCode ? "invert()" : null)
Array.from(document.querySelectorAll("img")).map(img => img.style.filter = invertImages ? "invert()" : null)
})(/* Invert Image | Invert Code | Dark BG */ 1, 0, 1)
@Odepax
Odepax / Document.parseElements.js
Created September 21, 2019 10:37
Javascript DOM extensions
/** Converts given string into DOM tree, and extract elements marked with 'id' attributes. */
Document.prototype.parseElements = function parseElements(/** @type {string} */ htmlString) {
const div = this.createElement("div")
div.innerHTML = htmlString
const identifiedElements = {}
for (const element of div.querySelectorAll("[id]")) {
identifiedElements[element.getAttribute("id")] = element
@Odepax
Odepax / Object.apply.js
Created September 21, 2019 10:35
Javascript Object.apply
Object.prototype.apply = function apply(/** @type {{ [prop: string]: any }|((it: any) => void)} */ init) {
if (typeof init == "function") {
init(this)
} else {
Object.assign(this, init)
}
return this
}
@Odepax
Odepax / Promise.delay.js
Created September 21, 2019 10:32
Javascript Promise.delay
/** Returns a promise that resolves after 'timeout' ms. */
Promise.delay = function delay(/** @type {number} @description Unit: ms. */ timeout, value = undefined) {
return new Promise(resolve => setTimeout(() => resolve(value), timeout))
}
@Odepax
Odepax / Read-SingleFileWebComponent.ps1
Last active September 15, 2019 09:05
Reading VueJs-like single-file components with Powershell, premise for other manipulations...
# https://www.business.com/articles/powershell-read-xml-files/
# https://stackoverflow.com/questions/11685265/casting-in-powershell-weird-syntax#answer-11685318
$k = (([Xml]("<R>" + (Get-Content -Path ".\sfc.html") + "</R>")).R)
Start-Something -With $k.style
Start-Something -With $k.template
Start-Something -With $k.script
@Odepax
Odepax / FrontEndDesignTests.kt
Created July 7, 2018 15:26
Who said manual testing couldn't be automated?
package io.github.odepax.another.webapp
import org.junit.jupiter.api.Test
import java.util.Calendar
class FrontEndDesignTests {
private val months = 60 * 60 * 24 * 30
@Test
fun `displays correctly on all platforms`() {
@Odepax
Odepax / 1-PowerShell-Tips.md
Last active December 1, 2023 09:33
What I Understand about PowerShell Approved Verbs

PowerShell Tips

Write-Host vs Write-Output

Write-Host writes directly to the console; Write-Output writes to the pipeline, which often ends up to the console but not necessarily.

For example: Write-Host "The Cake is a lie" | Out-Null won't work as expected, Write-Output "The Cake is a lie" | Out-Null will.

False Friends

@Odepax
Odepax / build.gradle
Created March 3, 2018 21:24
Gradle + Kotlin + Spek + Jacoco (March 2018)
//
// [ INFO ]
//
// Date: 2018-03-03
// Works on: [ ? Linux ] [ Y Windows ] [ ? MacOSX ]
// Gradle: 4.6.0
// Kotlin: 1.2.30
// Spek: 1.1.5
// JUnit Platform: 1.0.0
// Jacoco: 0.8.0