Skip to content

Instantly share code, notes, and snippets.

@warrenkc
warrenkc / information.md
Last active October 18, 2026 03:00
FAF Forged Alliance on M1 MacOS

Here is the breakdown of why using existing libraries as-is failed and required building our custom-patched JIT runtime:


1. The Stock Rosetta 2 Problem (Desync & Precision)

  • Rosetta 2 by default emulates x87 with native ARM64 NEON scalar floats (IEEE-754 64-bit double):
    • Real x86 CPUs execute x87 code on 80-bit extended-precision hardware registers and strictly adhere to the precision control field in the x87 Control Word (CW.PC).
    • In Supreme Commander: Forged Alliance, the physics and simulation loop switches CW.PC to 24-bit single-precision mode (0x007F).
    • Stock Rosetta 2 ignores CW.PC completely and computes intermediate operations at 53-bit double precision.
  • Rosetta also aggressively fuses multiply-add operations into ARM64 FMA (fmadd/fmsub), which rounds only once at the end instead of twice (real x87 multiplies, rounds, adds, and rounds again).
@warrenkc
warrenkc / internet-security-tips.txt
Created April 29, 2026 01:04
Internet Security Tips by Warren
Internet Security Tips by Warren
(I tried to order these in order or importance.)
1: https://www.usa.gov/credit-freeze
When you place a security freeze, creditors cannot access your credit report. This will keep them from approving any new credit account in your name, whether it is fraudulent or legitimate.
To let lenders and other companies access your credit files again to create new accounts, you will need to lift your credit freeze permanently or temporarily.
// https://documentation.mailgun.com/docs/mailgun/api-reference/openapi-final/tag/Routes/#tag/Routes/operation/post-v3-routes
// This sample works with .net framework
private static async Task<Route> CreateRoute(string recipientAddress, string forwardAddress)
{
RestClientOptions options = new RestClientOptions(new Uri("https://api.mailgun.net/v3"));
options.Authenticator = new HttpBasicAuthenticator("api", ApiKey);
using (RestClient client = new RestClient(options))
{
//Url encoded format, example: https://example.com/api?priority=0&description=it%27s+a+new+route&expression=match_recipient%28%22user%40example.com%22%29&action=%5B%27forward%28%22forward%40example.com%22%29%27%5D
@warrenkc
warrenkc / example.py
Created November 14, 2024 08:58
Mailgun API Create Route
# Example from Mailgun: https://documentation.mailgun.com/docs/mailgun/api-reference/openapi-final/tag/Routes/#tag/Routes/operation/post-v3-routes
import requests
url = "https://api.mailgun.net/v3/routes"
data = {
"priority": "0",
"description": "it's a new route",
"expression": "match_recipient('.*@gmail.com')",
"action[0]": "forward("http://myhost.com/messages/")"
@warrenkc
warrenkc / openai-api-json-format.cs
Created October 24, 2024 08:00
To turn on JSON mode with the Chat Completions or Assistants API you can set the response_format to { "type": "json_object" }.
Dictionary < string, string > responseFormat = new Dictionary < string, string > {
{
"type",
"json_object"
}
};
var payload = new {
model = "gpt-4o-mini",
messages = messages,
max_tokens = 300,
@warrenkc
warrenkc / sample.py
Created July 26, 2024 10:52
AWS Amazon Transcribe Python - Don't output partial results
async def handle_transcript_event(self, transcript_event: TranscriptEvent):
# This handler can be implemented to handle transcriptions as needed.
# Here's an example to get started.
results = transcript_event.transcript.results
for result in results:
if not result.is_partial:
for alt in result.alternatives:
print(alt.transcript)
@warrenkc
warrenkc / convert-celcius-to-fahrenheit.ps1
Last active April 2, 2023 01:01
Convert Celcius to Fahrenheit: Powershell Script
# Load WPF assemblies
Add-Type -AssemblyName PresentationFramework
# Define XAML code for the GUI
[xml]$xaml = @"
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Celsius to Fahrenheit Converter" Height="250" Width="400">
<Grid>
<Label Content="Celsius:" HorizontalAlignment="Center" Margin="0,40,0,0" VerticalAlignment="Top" FontSize="16" FontWeight="SemiBold"/>
@warrenkc
warrenkc / SquareTokenTest.js
Created November 15, 2022 03:04
SquareTokenTest.js
const appId = 'sq0idp-yCB3jRpR0PbPfffcFBEVbA';
const locationId = 'LGB4QKD1ME9BE';
const username = 'xxxx';
const amount = '500';
const partyId = 'xx';
const winningBidderId = 'xxxx';
const auctionGroupId = 'xxxx';
async function initializeCard(payments) {
const card = await payments.card();
@warrenkc
warrenkc / square-create-payment-link.py
Created October 28, 2022 06:31
Create payment link for Square in Python
@warrenkc
warrenkc / fix-wol-bible reading.js
Last active November 29, 2022 01:47
Fix bible reading from https://wol.jw.org/id for text to speech in Indonesian
// For https://wol.jw.org/ms Bible reading in Edge browser using text to speech. This will allow the browser to read the text without the verse numbers being read.
// Add chapter to chapter number
var elements = document.querySelectorAll('.cl');
element = elements[0]
var chapterNumber = element.innerText.trim()
element.innerText = `Pasal ${chapterNumber}: `
// Turn off reference symbols.
elements = document.querySelectorAll('.toggle');