Random snippets of all sorts of code, mixed with a selection of help and advice.
CoreImage: Store LUT in a CIImage and sample from it in a shader
20 May 2026 @ 8:51 pm
I am working on a tonemapper (see this repository) which I implement using a CIFilter.
On my branch simplerFirstStep, I store parameters in a CIImage which I pass to the metal shader which corrects the lightness of the image.
// calc my parameters here (these are correct)
let f_G = calcToneCurve(globLuminance: globLuminance,
segBorders: segmentationBorders,
means: means)
// store in a Databuffer
let lut = f_G.withUnsafeBufferPointer { Data(buffer: $0) }
// create CIImage with dims 256x1 pixel containing the data
let lutImage = CIImage(bitmapData: lut,
bytesPerRow: MemoryLayout<Float32>.size * f_G.count,
size: CGSize(width: f_G.count, height: 1), // 256x1 pixel
format: .Rf,
colorSpace: n
Is a webview dominant app with native-like transitions possible?
20 May 2026 @ 8:43 pm
During the last few months I built a website (nextjs) with a member dashboard, now I am building the mobile (expo) counterpart. The website changes all the time, and I do not have the time or the money to have a dedicated mobile codebase, therefore I am building it completely out of webviews.
Both website and mobile have the same file router structure, so each index.tsx just has a Webview with uri set to its current pathname and that correctly routes to the corresponding website page.
The problem is the navigation sucks. I dont want to just have a continuous webview with typical safari-like navigation, I want smooth inter-screen navigation.
Problems:
The tabs transition is ok but you cant swipe between them, additionally loading 4 webviews at once (4 tabs in the dashboard) worries me performance wise. I could just load one at a time, but then every new tab (even if you just visited it) will have to be reloaded.
The stack transiti
Nothing happens on a vanilla ajax request
20 May 2026 @ 8:41 pm
I'm trying to do some ajax in completely vanilla javascript — no libraries. And simply nothing happens. Nothing shows up in the network tab. Nothing shows up in the console tab. No errors. No HTTP requests. Nothing. I've created a simple standalone version below.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Title</title>
</head>
<body>
<script>
function JSON_to_URLEncoded(element,key,list){
// https://gist.github.com/lastguest/1fd181a9c9db0550a847
var list = list || [];
if(typeof(element)=='object'){
for (var idx in element)
JSON_to_URLEncoded(element[idx],key?key+'['+idx+']':idx,list);
} else {
list.push(key+'='+encodeURIComponent(element));
}
return list.join('&');
}
var xhr = new XMLHttpRequest();
xhr.open("POST", "/ajax.php", true);
xhr.setRequestHeader("Content-Type", "application
Is 'sleep .1' in swaybar status_command bad?
20 May 2026 @ 8:34 pm
To add more status to my sway-bar, I created a Shell script and used it in my Sway config file (~/.config/sway/config), in the bar section.
This is the Shell script (~/.config/sway/status.sh):
#!/bin/sh
BAT_CAPACITY=$(cat /sys/class/power_supply/BAT1/capacity)
BAT_STATUS=$(cat /sys/class/power_supply/BAT1/status)
DATETIME=$(date +'%Y-%m-%d %X')
VOLUME=$(wpctl get-volume @DEFAULT_SINK@)
echo "${VOLUME} | ${BAT_CAPACITY}% ${BAT_STATUS} | ${DATETIME}"
Where the script is being used (~/.config/sway/config):
bar {
position top
# When the status_command prints a new line to stdout, swaybar updates.
# The default just shows the current date and time.
status_command while ~/.config/sway/status.sh; do sleep .1; done
}
My question is whether using sleep .1 or sleep 0 in this case is bad, an
How to hide and disable Android navigation bar
20 May 2026 @ 8:33 pm
I am developing a full screen app. To show it, I use this in `initState` method:
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
That way, bar is hidden, however, it get back when user swipe from the edge, what I don't want.
How can I disable that feature completely?
Jaime
Multiple delimited strings insert in nested while loop
20 May 2026 @ 8:01 pm
I'm using SQL Server 2014 so no split string function is available.
I have two delimited strings (Brand and Location) to insert in my stored procedure to create (potentially) multiple rows in the destination table.
This is my stored procedure:
ALTER PROCEDURE [dbo].[Add_Reviewer]
@FirstName NVARCHAR(MAX)
,@LastName NVARCHAR(MAX)
,@Email NVARCHAR(MAX)
,@Brand NVARCHAR(MAX)
,@Location NVARCHAR(MAX)
,@Department NVARCHAR(MAX)
,@ProductLine NVARCHAR(MAX)
AS
BEGIN
WHILE CHARINDEX('|', @Location) > 0
BEGIN
DECLARE @templocation VARCHAR(max)
SET @templocation = SUBSTRING(@Location, 1, ( CHARINDEX('|', @Location) - 1 ))
WHILE CHARINDEX('|', @Brand) > 0
BEGIN
DECLARE @tempbrand VARCHAR(max)
SET @tempbrand = SUBSTRING(@Brand, 1, ( CHARINDEX('|', @Brand) - 1 ))
INSERT INTO [Reviewers] ([FirstName], [LastName],
Templates for C#
20 May 2026 @ 7:32 pm
I am just starting to learn C# and I want to build a robust and well-structured console application as my first project. While I understand the basic syntax like Console.WriteLine and Console.ReadLine, I am not entirely sure about the best practices for structuring a slightly larger console app.
Specifically, I am looking for advice, best practices, or starter templates regarding:
How to properly structure the main loop and handle menu navigation.
How to cleanly separate the core logic from the user interface (console input/output).
Are there any standard design patterns or recommended boilerplate setups for modern C# console applications?
Any guidance, recommended resources, or GitHub template links to help me start on the right foot would be greatly appreciated. Thank you in advance!
How to Replace Text on Many Character Sheets in Google Sheets
20 May 2026 @ 6:59 pm
I have over 500 documents which I need to change at my job. These are character sheets for a live action role playing group. All of them share the same format.
Right now there is text in many of the cells but I need to change the text in certain cells on every document. Is there a function or a specialized use of find/replace I can use to change all of this text.
This is all done in google sheets.
I need the following outcomes:
-current text in T13 replaced with "Grapple/Resist Grasp"
-current text in C 21 replaced with "Telepathy* or Break Focus"
-current text in L20 replaced with "Dispel MAgic/M. Sense"
-current text in C32 replaced with "Identify or I Have an Idea"
-current text in C33 replaced with "Fix It or Break It^"
-Current Text in C34 replaced with "Weapon Power"
-Current Text in AA20 replaced with "Arcanist"
This image is ho
Sync reset used as async reset
20 May 2026 @ 6:52 pm
I'm looking at a Verilog module that handles reset in an unusual way:
An async reset input goes through a synchronizer chain of flip-flops
The synchronized reset output (sync_rst_n) is then used in the sensitivity list like an async reset:
"always @(posedge clk or negedge sync_rst_n)"
This seems incorrect. Even though sync_rst_n went through synchronization, using it in the sensitivity list means it's being treated as an asynchronous signal again. This bypasses the timing analysis that applies to normal synchronous paths.
Potential issues I see:
Clock skew between different registers could cause them to exit reset on different clock cycles
Static timing analysis may not properly constrain sync_rst_n when it's used asynchronously
Is this assessment correct?
How to create a function object from a non static member function
20 May 2026 @ 6:43 pm
I'm still pretty new to how function objects work in C++. I'm trying to create a function object that maps to a non static member function of a class. Here's what I'm trying to do:
#include <functional>
template<typename T, T v>
struct MyClass
{
T internal_state;
T foo()
{
T x = v;
internal_state = v;
return x;
}
};
int main()
{
MyClass<int, 20> obj;
std::function f0 = obj.foo; // Try 1
std::function f1 = std::bind(obj.foo, &obj, std::placeholders::_1); // Try 2
std::function f2 = std::bind(decltype(obj)::foo, &obj, std::placeholders::_1); // Try 3
std::function f3 = std::bind(&decltype(obj)::foo, &obj, std::placeholders::_1); // Try 4
return f();
}
I wanna create a function object that maps to the function foo of MyClass. I need this function to not be a static function. I tried using std::function to create a fu