Skip to content

Instantly share code, notes, and snippets.

View jflopezfernandez's full-sized avatar
🏈
Merry Start of the Football Season Eve!!!

Jose Fernando Lopez Fernandez jflopezfernandez

🏈
Merry Start of the Football Season Eve!!!
View GitHub Profile
@jflopezfernandez
jflopezfernandez / ga.py
Created August 14, 2022 06:27
Genetic algorithm - basic example
from __future__ import annotations
from enum import Enum, unique
from typing import Iterable, List, NewType, Text
from numpy.random import Generator, default_rng
@unique
class ItemType(Enum):
@jflopezfernandez
jflopezfernandez / primes.c
Created May 19, 2022 12:16
Prime factorization by trial division.
/**
* @file primes.c
* @author Jose Fernando Lopez Fernandez <[email protected]>
* @brief Prime factorization using trial division algorithm.
* @version 0.1
* @date 2022-05-18
*
* @copyright Copyright (c) 2022
*
* Compile and link using the following command.
@jflopezfernandez
jflopezfernandez / visualize.py
Created April 27, 2021 17:31
Bayesian update example for DAT-500
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
from numpy.random import default_rng
from scipy.stats import beta
class UpdateProbabilityDistribution:
@jflopezfernandez
jflopezfernandez / sshd_config.default
Created March 21, 2021 17:50
Arch Linux Default SSHD Server Configuration File
# $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/sbin:/usr/local/bin:/usr/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
@jflopezfernandez
jflopezfernandez / rc4.c
Created November 26, 2020 19:03
RC4 Stream Cipher Encryption Algorithm
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <errno.h>
@jflopezfernandez
jflopezfernandez / cmake.yml
Created November 21, 2020 07:03
Experimental GitHub workflows refactor for Check
name: Check CMake Buildsystem CI Workflow
on:
push:
branches: [ $default-branch ]
pull_request:
branches: [ $default-branch ]
jobs:
build:
@jflopezfernandez
jflopezfernandez / main.c
Last active October 25, 2020 15:45
MSVC 2019 Preprocessor Output
#line 1 "main.c"
#line 5 "main.c"
#line 1 "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\ucrt\\stdio.h"
#pragma once
#line 1 "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\ucrt\\corecrt.h"
@jflopezfernandez
jflopezfernandez / windows-x64-msvc-release-build.log
Created October 25, 2020 14:47
Build log from MSVC 2019 release build
C:\Users\jflop\check-build>cmake --build . --config Release
CMake is re-running because C:/Users/jflop/check-build/CMakeFiles/generate.stamp is out-of-date.
the file 'C:/Users/jflop/source/repos/check/CMakeLists.txt'
is newer than 'C:/Users/jflop/check-build/CMakeFiles/generate.stamp.depend'
result='-1'
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/jflop/check-build
Microsoft (R) Build Engine version 16.7.0+b89cb5fde for .NET Framework
@jflopezfernandez
jflopezfernandez / sample-strlen.asm
Created October 21, 2020 17:48
Sample strlen implementation for x86-64 linux
GLOBAL _start
SECTION .data
str: db "Hello, world!",0x0A,0x00
len: equ $-str
errstr: db "Null-terminator not found.",0x0A,0x00
errlen: equ $-errstr
@jflopezfernandez
jflopezfernandez / generate-nasm-syscalls.sh
Created October 21, 2020 16:41
Generate NASM include file of Linux x86-64 system calls from /usr/include/asm/unistd_64.h
#!/usr/bin/bash
cat /usr/include/asm/unistd_64.h | sed -E 's/__NR_//' | awk '{ $1 = ""; print; }' | perl -nE 'print if tr/a-z/A-Z/;' | sed -E 's/^(.*)$/%define\1/' | awk '{ $2 = "SYSCALL_" $2; print; }' > syscalls.inc