Skip to content

Instantly share code, notes, and snippets.

View Miliox's full-sized avatar

Emiliano Firmino Miliox

View GitHub Profile
@Miliox
Miliox / plain_b64.c
Last active November 15, 2021 19:16
Plain Base64
#include <stdio.h>
const char kBase64Alphabet[64] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '-'
};
const char kBase64Padding = '=';
@Miliox
Miliox / gist:9a547ae5467a31df50013fad48e0879b
Created August 19, 2021 08:53
Scan Parts using NetCat
nc -zvn <target> <begin-port>-<end-port>
@Miliox
Miliox / stacktrace.h
Last active April 30, 2020 07:54
Simple stack trace
#include <execinfo.h>
#define PRINT_STACKTRACE(TAG) \
{ \
void* buffer[256]; \
int count = backtrace(buffer, 256); \
\
char** calls = backtrace_symbols(buffer, count); \
if (calls != nullptr) \
{ \
@Miliox
Miliox / gist:cdeb01de88bc6efbdce2ffa81a75ec45
Created May 14, 2018 18:29
Mac Jump to Begining/Ending of Line on Terminal
https://stackoverflow.com/questions/6205157/iterm-2-how-to-set-keyboard-shortcuts-to-jump-to-beginning-end-of-line
FOR ACTION SEND
⌘← "SEND HEX CODE" 0x01
⌘→ "SEND HEX CODE" 0x05
# Command Line Progress Viewer for many tools
sudo apt-get install libncurses5-dev
git clone https://github.com/Xfennec/progress.git
# Random Cowsay Message and Cow
fortune | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n 1)
# perform a fresh install of Ubuntu 17.10
# upgrade the kernel to v4.13.10
mkdir ~/kernel-v4.13.10
cd ~/kernel-v4.13.10
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13.10/linux-headers-4.13.10-041310_4.13.10-041310.201710270531_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13.10/linux-headers-4.13.10-041310-generic_4.13.10-041310.201710270531_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13.10/linux-image-4.13.10-041310-generic_4.13.10-041310.201710270531_amd64.deb
sudo dpkg -i *.deb
@Miliox
Miliox / gb_info.txt
Created September 8, 2017 17:00
Gameboy Programming Info
Programming Info
Information about GameBoy hardware and programming is extremely hard to find. Most of it is incomplete, uncertain and vague. If you have any new information, PLEASE, email it to me. The following information is mostly based on a document by Pan of Anthrox, Jeff Frohwein's, Pascal Felber's, and my own findings.
Memory Map
--------------------------- FFFF | 32kB ROMs are non-switchable and occupy
I/O ports + internal RAM | 0000-7FFF are. Bigger ROMs use one of two
--------------------------- FF00 | different bank switches. The type of a
Internal RAM | bank switch can be determined from the
@Miliox
Miliox / program_profile.sh
Created August 28, 2017 05:23
Script SAR (kSar Compatible)
#!/bin/bash
#Autor: Emiliano Carlos de Moraes Firmino
#Comentario: igual a usar "sar -A 1", mas sem a interface de rede
# que não abre no kSar
#Script Variables
output_file="sar_data.txt" #arquivo de saída
interval=1 #taxa de amostragem em segundos
#Inicia rodada de testes
There are many small errors or discrepancies in the docs listed above, unfortunately I don't know if/how those docs are maintained so I'm going to list the errors I've found here for now:
RLCA instruction: various sources disagree on whether the Z flag should be modified by the operation. After some research I'm pretty sure it shouldn't be modified (the Z80 processor for instance does not modify Z).
HALT instruction: when this instruction is executed while interrupts are disabled in the CPU (for instance by a DI instruction) the CPU will still be awoken by any interrupt enabled in the IE register, however the interrupt handler will not be run and the control will be given back to the code that called the HALT. Be careful that the instruction following an HALT is glitchy but that's well documented.
ADD SP,N (opcode 0xe8) and LDHL SP,N (opcode 0xf8): the values of the carry and halfcarry are computed on the low 8bits.
RLCA, RLA, RRCA, RRA instructions: the flags are described wrong in the CP
@Miliox
Miliox / main.c
Created June 15, 2017 13:38
JSON C Parsing Example
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "jsmn.h"
char* types[] = {"UNDEFINED", "OBJECT", "ARRAY", "STRING", "PRIMITIVE"};
int main() {
char* json = NULL;
size_t len = 0;