Skip to content

Instantly share code, notes, and snippets.

@tivrfoa
tivrfoa / ripgrep-code-components.md
Created February 28, 2025 17:18
ripgrep analysis
@tivrfoa
tivrfoa / C_and_C-Tiberian-Dawn-BULLET.CPP.md
Created February 28, 2025 16:47
C&C Tiberian Dawn Bullet.CPP Analysis by Google AI Studio Gemini 2.0 Pro Experimental 02-05

Let's break down the BULLET.CPP code from the Command & Conquer: Tiberian Dawn Remastered Collection source. This file defines the behavior of bullets (and similar projectiles) within the game.

Core Concepts and Purpose

This file is responsible for:

  1. Bullet Creation: Defining how bullets are spawned (created) in the game world.
  2. Bullet Movement: Handling the trajectory and movement of bullets across the map.
  3. Bullet Impact: Determining what happens when a bullet hits something (a unit, building, or terrain).
  4. Bullet Lifetime: Managing how long a bullet exists before disappearing.
@tivrfoa
tivrfoa / java-interview-question-recursion.md
Created February 23, 2025 13:42
Prompting ChatGPT: write a Java interview question where recursion is a good solution

Java Interview Question: Using Recursion to Solve a Problem

Question:

You are given a nested list of integers, where each element is either an integer or another list of integers. Implement a function in Java that sums all integers in the nested list, regardless of how deeply nested they are.

Example Input:

List<Object> nestedList = List.of(1, List.of(2, 3, List.of(4, 5)), 6);

Expected Output:

@tivrfoa
tivrfoa / java-interview-question-using-HashMap.md
Created February 23, 2025 10:37
Prompting ChatGPT: Create a Java interview question where the solution needs to use a HashMap

Java Interview Question: Using HashMap for Frequency Counting

Question:

You are given a list of words, and your task is to find the top N most frequent words in the list. Implement a function that efficiently counts word occurrences and returns the top N words sorted by frequency.

Requirements:

  1. Efficiently count the occurrences of each word.
  2. Retrieve the top N words sorted by frequency.
  3. If two words have the same frequency, they should be sorted alphabetically.
  4. Assume the input is a large dataset, so efficiency matters.
@tivrfoa
tivrfoa / java-interview-question-usuing-enum.md
Created February 23, 2025 10:30
Prompting ChatGPT: Create a Java interview question, where using enum is the best solution

ChatGPT:

Java Interview Question:

Question:
You are designing a system that processes customer orders. Each order has a status that can change over time. The possible statuses are:

  • NEW (Order just created)
  • PROCESSING (Currently being processed)
  • SHIPPED (Sent to the customer)
@tivrfoa
tivrfoa / Grok3-hpack.c
Created February 20, 2025 09:36
Testing Grok 3 - Write an HPACK implementation in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
// --- Data Structures ---
// Header entry structure for static and dynamic tables
typedef struct {
@tivrfoa
tivrfoa / JavaScript-auto-unwrapping-of-promises-in-async-functions.md
Created February 17, 2025 22:31
JavaScript - Auto-Unwrapping of Promises in `async` Functions

Prompting ChatGPT:

I think the following is a strange behavior in JavaScript:

Promises auto-unwrap, so if you do return a promise for a value from within an async function, you will receive a promise for the value (not a promise for a promise for the value).

function defer(callback) {
  return new Promise(function(resolve) {
    setTimeout(function() {
@tivrfoa
tivrfoa / DeepSeek-R1-distill-llama-70B-types-supported-in-Python-3.md
Created February 12, 2025 10:42
DeepSeek R1 distill llama 70B on groqcloud answer to: what types are supported in Python 3?
Okay, the user just asked, "what types are supported in Python 3?" Looking back at the conversation history, I had previously explained Python 3 in detail, covering its features, advantages, and applications. Now, the user is diving deeper into the specifics of data types.

I need to provide a comprehensive yet clear answer. The user might be a programmer looking to understand the data types available or a student trying to learn Python. They might be working on a project and need to know which types to use in different scenarios.

I should start by categorizing the data types. Maybe separate them into standard types, numeric types, sequence types, mapping types, set types, boolean, NoneType, dictionary views, file types, and others. That way, it's organized and easier to follow.

I should explain each type with examples. For instance, under numeric types, I can mention int, float, complex, and their syntax. For sequences, list, tuple, and string, each with examples. This helps the user see how they'r

@tivrfoa
tivrfoa / garbage-collection-vs-manual-memory-management-chatgpt-answer.md
Created February 9, 2025 12:25
when does Garbage collection is faster than manual memory management?

Garbage collection (GC) can sometimes be faster than manual memory management in specific scenarios due to its ability to optimize allocations, reduce fragmentation, and efficiently manage short-lived objects. Here are some situations where GC outperforms manual memory management:

1. Frequent Short-Lived Object Allocations

  • Languages with GC (e.g., Java, Go, C#) often use generational garbage collection, where short-lived objects are allocated in the "young generation" (or equivalent), which is optimized for fast allocation and collection.
  • Example: In a high-throughput web server, frequent allocation and deallocation of request objects can be handled efficiently by GC with minimal overhead.

2. Avoiding Fragmentation

  • Manual memory management (e.g., malloc/free in C, new/delete in C++) can lead to heap fragmentation, slowing down future allocations.
  • GC-based memory managers often use compaction to reduce fragmentation, leading to **faster allocati
@tivrfoa
tivrfoa / init.lua
Created January 16, 2025 10:54
Neovim init.lua
-- require("config.lazy")
-- Set the leader key
vim.g.mapleader = " "
-- General settings
vim.opt.cc = "120"
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.autoindent = true