Skip to content

Instantly share code, notes, and snippets.

View dhinojosa's full-sized avatar

Daniel Hinojosa dhinojosa

View GitHub Profile
@dhinojosa
dhinojosa / TicTacToe.java
Created August 8, 2024 15:47
Made by AI, needs refactoring
import java.util.Scanner;
public class TicTacToe {
private static char[][] board = new char[3][3];
private static char currentPlayer = 'X';
public static void main(String[] args) {
initializeBoard();
playGame();
@dhinojosa
dhinojosa / C64Emulator.java
Created June 5, 2024 15:18
ChatGPT Commodore 64 Emulator
import java.util.Arrays;
public class C64Emulator {
private static final int MEMORY_SIZE = 65536; // 64KB memory
private byte[] memory = new byte[MEMORY_SIZE];
// 6502 CPU registers
private int pc; // Program Counter
private byte sp; // Stack Pointer
@dhinojosa
dhinojosa / VirtualThreadsTryWithResources.java
Created March 24, 2024 23:02
The following hangs when using ExecutorService in TWR block
package com.evolutionnext.demo.virtualthreads;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.concurrent.*;
@dhinojosa
dhinojosa / FindAllJavaWordsFromURL.java
Last active March 24, 2024 20:22
Does this deadlock for you?
package com.evolutionnext.demo.virtualthreads;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.concurrent.*;
@dhinojosa
dhinojosa / UsingGathererGroupBy.java
Last active March 10, 2024 22:26
GroupBy as a Gatherer
static class GroupBy<T, K> implements Gatherer<T, HashMap<K, List<T>>, Map.Entry<K, List<T>>> {
private final Function<T, K> groupFunction;
public GroupBy(Function<T, K> groupFunction) {
this.groupFunction = groupFunction;
}
@Override
public Supplier<HashMap<K, List<T>>> initializer() {
@dhinojosa
dhinojosa / git_repo_check.sh
Last active February 29, 2024 18:26
Find all the repositories in your home directory and tells you what needs to be updated. Run with ./git_repo_check <dir1> <dir 2>
#!/bin/bash
# Function to check a single git repository
check_git_repo() {
local dir=$1
cd "$dir" || return
# Check for uncommitted changes
uncommitted_changes=$(git status --porcelain)
if [ ! -z "$uncommitted_changes" ]; then
import java.util.concurrent.ExecutionException;
import java.util.concurrent.StructuredTaskScope;
import java.util.concurrent.atomic.AtomicLong;
public class MillionsOfTasks {
private final AtomicLong atomicLong;
public MillionsOfTasks() {
atomicLong = new AtomicLong();
}
[
{
"type": "record",
"namespace": "MyEvents",
"name": "PhoneNumber",
"fields": [
{
"name": "countryCode",
"type": "string"
},
@dhinojosa
dhinojosa / public.adoc
Created September 6, 2023 16:21
Sample adoc public

Test

  • One

  • Two

  • Three

apiVersion: v1
kind: Pod
metadata:
annotations:
dns.alpha.kubernetes.io/internal: api.internal.dik8ssecurity01.k8s.local
kubectl.kubernetes.io/default-container: kube-apiserver
creationTimestamp: null
labels:
k8s-app: kube-apiserver
name: kube-apiserver