Skip to content

Instantly share code, notes, and snippets.

Modifiers

  • It's a special kind of function that modifies the behavior of other functions
  • underscore _:
    • placeholder that represents the body of the function being modified
    • execution sequence: code before _ -> code of modified function -> code after _
modifier exampleModifier {
 // This code is executed first
@codekoriko
codekoriko / files-to-GPT.ps1
Last active December 28, 2023 05:23
helper to provide context to ChatGPT requests
param (
[string[]]$Paths,
[string[]]$Exclude
)
# Check if at least one path is provided
if (-not $Paths) {
Write-Host "Please provide at least one file or directory path."
Exit
}
@codekoriko
codekoriko / WemosD1-A1-SPIFFS-formating.cpp
Last active December 1, 2023 17:15
Arduino - snippets
#include "FS.h"
String realSize = String(ESP.getFlashChipRealSize());
String ideSize = String(ESP.getFlashChipSize());
bool flashCorrectlyConfigured = realSize.equals(ideSize);
void setup() {
Serial.begin(115200);
if(flashCorrectlyConfigured) SPIFFS.begin();
else Serial.println("flash incorrectly configured, SPIFFS cannot start, IDE size: " + ideSize + ", real size: " + realSize);
@codekoriko
codekoriko / Readme.md
Last active March 22, 2024 11:42
for Dual Display: calculate both display extends and Shift cursor from one display to the other on a key press

For Windows Users only

On Dual Display setup, I found it frustrating that the cursor is not bounded to sides of the display anymore. For example reaching the "close window" button needs precise muscle control whereas before you could simply crash again the top & right screen border and smash that window.

So I keep both display separated and created an AutoHotKey script to shift the cursor from my first to my second display on a press of a button.

Setup:

Separate both Display

  • Win+S -> search: "extend" -> "Duplicate or extend a connected Display"
  • Move display 2 far away to the Top/bottom left/right corner.
@codekoriko
codekoriko / status.json
Last active February 4, 2024 00:30
WowRelayer
{
"last_seen_alive_date": "2024-02-04T00:30:59.435283",
"last_magic_packet_sent": "",
"time_live": "11:00:46.804267"
}
@codekoriko
codekoriko / json_datetime_encoder.py
Last active May 13, 2021 03:24
json datetime encoder
class DateTimeEncoder(json.JSONEncoder):
def _preprocess_date(self, obj):
if isinstance(obj, (datetime.date, datetime.datetime, datetime.timedelta)):
return str(obj)
elif isinstance(obj, dict):
return {self._preprocess_date(k): self._preprocess_date(v) for k,v in obj.items()}
elif isinstance(obj, list):
return [self._preprocess_date(i) for i in obj]
return obj
@codekoriko
codekoriko / generate.sh
Created October 23, 2020 18:21 — forked from rapgru/generate.sh
Color Scheme List for Windows Terminal Configuration based on https://github.com/Mayccoll/Gogh
#!/bin/bash
# call this from inside the /themes folder of https://github.com/Mayccoll/Gogh
# do not place this as .sh file into /themes as this leads to double execution
createColors() {
source $1
# White -> brightWhite
# Light gray -> white