Skip to content

Instantly share code, notes, and snippets.

View Apocryphon-X's full-sized avatar
🌙
I'm pursuing something unattainable

Dante Mendoza Apocryphon-X

🌙
I'm pursuing something unattainable
  • National Polytechnic Institute
  • Redmond, WA (Originally from 🇲🇽)
  • 10:20 (UTC -07:00)
View GitHub Profile
#include <iostream>
#include <string>
struct color {
short r;
short g;
short b;
};
std::string as_24bit_ansi(color values) {
@harkabeeparolus
harkabeeparolus / Typer_cheat_sheet.md
Last active April 19, 2024 04:53
Typer — my attempt at reference documentation
@nschloe
nschloe / write-comparison.py
Created January 27, 2023 21:42
Python array I/O comparison
from sys import version_info
import matplotlib.pyplot as plt
import perfplot
import pickle
import netCDF4
import numpy as np
import h5py
import tables
@Apocryphon-X
Apocryphon-X / Reflection-Module.md
Last active May 31, 2024 17:08
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.

@Apocryphon-X
Apocryphon-X / wb-combined.c
Last active November 23, 2023 04:37
Sillicon Valley S03E01 Code - Final Output: 'DREAM_ON_ASSHOLES'
#include <stdio.h>
#include <stdlib.h>
typedef unsigned long u64;
/* Start here */
typedef void enc_cfg_t;
typedef int enc_cfg2_t;
typedef __int128_t dcf_t;
@Apocryphon-X
Apocryphon-X / execute
Last active June 4, 2023 18:18
C++ compiling tool (g++ wrapper). Written for competitive programming and personal use.
#!/usr/bin/python3
# Copyright (c) 2022 @Apocryphon (Dante Mendoza Leyva).
# All rights reserved.
import subprocess
import click
import pathlib
import sys
@kkrypt0nn
kkrypt0nn / ansi-colors-discord.md
Last active July 9, 2024 17:13
A guide to ANSI on Discord

A guide to ANSI on Discord

Discord is now slowly rolling out the ability to send colored messages within code blocks. It uses the ANSI color codes, so if you've tried to print colored text in your terminal or console with Python or other languages then it will be easy for you.

Quick Explanation

To be able to send a colored text, you need to use the ansi language for your code block and provide a prefix of this format before writing your text:

\u001b[{format};{color}m

\u001b is the unicode escape for ESCAPE/ESC, meant to be used in the source of your bot (see ). If you wish to send colored text without using your bot you need to copy the character from the website.

@nschloe
nschloe / string-vs-list-lookup.py
Created November 13, 2021 12:05
Python string lookup vs list lookup speed
import random
import perfplot
lst = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"]
string = "abcdefghijkl"
def list_lookup(data):
return [lst[n] for n in data]
@Apocryphon-X
Apocryphon-X / chromedriver_without_images.py
Last active January 1, 2024 15:52
Disable image loading for Chromedriver using Python Selenium
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = webdriver.ChromeOptions()
prefs = {"profile.managed_default_content_settings.images": 2}
chrome_options.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://google.com/")
@Apocryphon-X
Apocryphon-X / selenium_disguise.py
Last active January 1, 2024 15:52
Create an instance of Google Chrome (using a Chromedriver) with no infobars and no webdriver console. Works with Python 3 and Selenium == 4.0.0b3.
from subprocess import CREATE_NO_WINDOW
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
service = Service("chromedriver.exe")
service.creationflags = CREATE_NO_WINDOW
chrome_options = webdriver.ChromeOptions()