Skip to content

Instantly share code, notes, and snippets.

View Apocryphon-X's full-sized avatar
🎉
This time, let's do things the right way.

Dante Mendoza Apocryphon-X

🎉
This time, let's do things the right way.
  • National Polytechnic Institute
  • México
  • 03:27 (UTC -06:00)
View GitHub Profile
try:
# pip install requests rich
import requests
from rich.console import Console
from rich.progress import Progress, SpinnerColumn, TimeElapsedColumn
from rich.traceback import install
from rich import inspect
from rich import print
except ImportError as e:
print(e, "- Is it installed?")
@Apocryphon-X
Apocryphon-X / template.cpp
Last active December 30, 2024 03:42
[C++] Template for Competitive Programming
#ifdef LOCAL
#define _FORTIFY_SOURCE 2
#define _GLIBCXX_DEBUG_PEDANTIC
#define _GLIBCXX_DEBUG
#define debug(x) \
std::cerr << std::boolalpha << "\x1b[33m[DEBUG] " \
<< #x" = " << x << "\x1b[0m\n"
#else
#define NDEBUG 1
#define debug(x) 1
@Apocryphon-X
Apocryphon-X / 1.toggle_led_using_button.vhd
Last active December 18, 2024 21:38
Every time the button is pressed, the chosen led changes from '0' to '1' or from '1' to '0' respectively. Button press takes effect only after 120μs of being held (assuming `clk` is assigned to a 100MHz clock).
-- * Author: Dante Mendoza Leyva
-- * Group: 4CV13
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
entity led_test is Port (
clk: in std_logic;
@Apocryphon-X
Apocryphon-X / 1.four_bit_number_select.vhd
Last active December 18, 2024 21:37
Display the selected 4-bits number in the seven segments display. (4-bit numbers can be edited using switches)
-- * Author: Dante Mendoza Leyva
-- * Group: 4CV13
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
entity seven_segments_driver is Port (
clk: in std_logic;
@Apocryphon-X
Apocryphon-X / 1.seven_segments_controller.vhd
Last active December 30, 2024 03:40
[VHDL] 7-Segment Display Controller designed to display the number "1515" as an example.
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
-- * Author: Dante Mendoza Leyva (4CV13)
entity seven_segments_controller is Port (
clk: in std_logic;
anodes: out std_logic_vector(3 downto 0);
display_glyph: out std_logic_vector(6 downto 0)
@Apocryphon-X
Apocryphon-X / args_analyzer.py
Last active December 18, 2024 21:40
`parse_argument_list` accepts a flags "register" as second argument to handle things like -h / --help or things like --debug flags!
"""
The MIT License (MIT)
Copyright (c) 2024 - Present, @Apocryphon-X (Dante Mendoza Leyva)
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
#include <iostream>
#include <string>
struct color {
short r;
short g;
short b;
};
std::string as_24bit_ansi(color values) {
@Apocryphon-X
Apocryphon-X / Profile-Comparer.py
Last active June 20, 2024 09:08
Small script to compare two omegaUp profiles (This tool shows you what problems user B doesn't have that user A does).
# MIT License: 2023 - Present
import requests
import os
import sys
import json
from rich import print
API_TOKEN = os.getenv("OMEGAUP_API_TOKEN")
@Apocryphon-X
Apocryphon-X / Segment Tree (Basic Structure).cpp
Last active December 23, 2022 04:33
Iterative implementation of the Segment Tree DS (Basic and non lazy). From: Antii Laaksonen CPHB.
#include <iostream>
using namespace std;
using i64 = long long;
// Memory Required: O(2N)
i64 Tree[i64(2e6) + 1];
i64 N, K, X;
// Puntual Update: O(log N)
@Apocryphon-X
Apocryphon-X / Reflection-Module.md
Last active April 8, 2025 00:39
Handy V module to simplify the use of compile-time reflection.

Quickstart

Functions available in this module:

  - reflection.(*)_of_type[foo]()  // Extract details from type or struct
  - reflection.(*)_of(bar)         // Extract details from type instance 
  
(*) can be `methods`, `fields` or `attributes`.

Each function returns a map[string]T where T can be FunctionData, FieldData or StructAttribute respectively.