Skip to content

Instantly share code, notes, and snippets.

View layomia's full-sized avatar

Layomi Akinrinade layomia

View GitHub Profile
Me:
I want to build a simple p5.js game where Harry Potter villains approach Harry in three lanes (like Beat Saber). Harry can move left/right, and if he’s in the right lane when a villain reaches him, he slays them; otherwise they pass. Track slayed vs passed, and end the game when the difference reaches ±5. Later, I asked for photorealism, then said I don’t have images—so just approximate in code. Finally, I asked to make the game feel more alive, with more depth and closer to my artistic style.
AI:
Provided a full p5.js implementation of the 3-lane game with movement, spawning enemies, hit detection, scoring, and game-over logic . Then upgraded it to support photorealistic sprites using PNG assets (with prompts for generating them), while keeping a fallback if images are missing . After that, created a fully code-based stylized version (no images) with recognizable character silhouettes . Finally, enhanced the game with richer visuals and “life”: beat-synced spawning, parallax corridor, particles (dust/sp
[Attached image and generated videos not shown]
video of going through a wormhole/time jumping. adding a lot of flashing/distortion and the movement of going through it
Gemini said
You said
16:9, 25s video of going through a wormhole/time jumping. adding a lot of flashing/distortion and the movement of going through it
Gemini said
Me:
I’m building a mood lamp with CPX. I want a hand swipe gesture to control it. Right swipe should turn it on, left swipe should turn it off, and I want swipe velocity to determine which mood gets activated. Can you help me define gesture rules and mood-state mapping?
AI:
Yes. A clean way to structure this is:
1. Gesture rules
Right swipe = activate lamp and select mood
@layomia
layomia / Program.cs
Last active July 3, 2023 16:46
ExtendedProgram.cs
using System.Text.Json.Serialization;
using AotWebApi;
using Microsoft.Extensions.Options;
var builder = WebApplication.CreateSlimBuilder(args);
builder.Services.ConfigureHttpJsonOptions(options =>
{
options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
});
namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
// Specifies options to honor when generating binding logic.
// Presence indicates that the source generator should be invoked for the current assembly.
public sealed class BindingSourceGenerationOptionsAttribute : Attribute
{
// Specifies the generation mode.
public BindingSourceGenerationMode GenerationMode { get; set; }
}

ConfigurationBinder source generator

Phase 1: Implement core binding functionality

Similar to fast-path JSON deserialization.

Current status Feature branch:

  • core infra & generation implemented
  • based on David's prototype which generates to global namespace, making compiler choose source-gen'd methods over framework methods
  • testing mechanism same as JSON (sharing tests with reflection-based implementation)
@layomia
layomia / README.md
Last active November 10, 2022 03:22
@layomia
layomia / JsonEscapingCheck.md
Created November 30, 2020 07:26 — forked from ahsonkhan/JsonEscapingCheck.md
Optimize the check to see whether a JSON string contains characters that need to be escaped.

The default behavior of the System.Text.Json JsonSerializer and Utf8JsonWriter follows the behavior of JavascriptEncoder.Default, which means the following character sets are escaped:

  • Any non-ascii character
  • Characters required escaping based on the JSON RFC
  • HTML-specific ascii characters

Current Approach

The current approach involves going through the list of characters, one at a time, and check whether that character needs escaping. We special case the "null" encoder (which is the default when the user doesn't specify their own) and use a 256 byte bit-mask to indicate which character needs to be escaped. https://github.com/dotnet/corefx/blob/52d63157c78c31816b81be1599a5dacf96b5e5ca/src/System.Text.Json/src/System/Text/Json/Writer/JsonWriterHelper.Escaping.cs#L82-L109

New Approach Chosen

using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace RefHandlingDemo
{
class Program
{
static void Main(string[] args)
@layomia
layomia / JsonIgnore_API_change.md
Last active March 23, 2020 21:04
JsonIgnore_API_change

Approach A

/// <summary>
/// Prevents a property from being serialized or deserialized.
/// </summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public sealed class JsonIgnoreAttribute : JsonAttribute
{
    /// <summary>