Skip to content

Instantly share code, notes, and snippets.

View Sam-Belliveau's full-sized avatar

Sam Belliveau Sam-Belliveau

View GitHub Profile
@Sam-Belliveau
Sam-Belliveau / Mandelbrot Set (GMP).cpp
Last active February 14, 2018 03:10
MY MANDELBROT RENDERER! You will need: SFML and GMP. You may change precision or resolution. It can use upto 16 cores/threads. Height must be a multiple of 16.
#include <SFML/Graphics.hpp>
#include <gmp.h>
typedef double num;
const unsigned int w = 256, h = 256;
const unsigned int p = 256;
sf::RenderWindow app(sf::VideoMode(w, h), "Mandelbrot Set");
@Sam-Belliveau
Sam-Belliveau / Timer.h
Last active July 2, 2018 22:05
This is a class that lets you time high performance tasks with ease. It can time 250+ years of nano second accurate time meaning you will never have to worry about overflowing. It uses chrono, which has the smallest tick speed, but makes it simple enough for a first grader to use. Chrono can make your code look messy with its name spaces and tem…
#ifndef TIMER_H
#define TIMER_H
#include <chrono>
template<class ClockT = std::chrono::high_resolution_clock, class Rep = uint_least64_t, class DefaultPeriod = std::nano>
class Timer
{
public:
@Sam-Belliveau
Sam-Belliveau / Fraction.hpp
Last active July 2, 2018 22:47
A very usable fraction library that should be plug and play.
/* MIT License
*
* Copyright (c) 2018 Samuel R. Belliveau
*
* 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 Software is
@Sam-Belliveau
Sam-Belliveau / NeuralNetwork.hpp
Last active March 21, 2019 18:35
This is a Neural Network enclosed in a C++ Class
#ifndef NEURALNETWORK_HPP
#define NEURALNETWORK_HPP
// size_t
#include <cstdint>
// Rand
#include <cstdlib>
#include <ctime>
@Sam-Belliveau
Sam-Belliveau / BitManipulation.h
Created August 27, 2018 14:52
This lets you do bit manipulation in C++
#ifndef BITMANIPULATION_H
#define BITMANIPULATION_H
#include <cstdint>
template<class T>
inline bool getBit(const T& input, const std::size_t& bit)
{
const T bitMask = 0x1 << bit;
return (input & bitMask) != 0x0;
@Sam-Belliveau
Sam-Belliveau / Generic.hpp
Last active September 7, 2018 23:22
This is a Generic Class. It's like std::byte, but it can be any size you want
#ifndef GENERIC_HPP
#define GENERIC_HPP 1
/*** Includes ***/
#include <cstdint> // std::size_t
#include <array> // std::array
/*** Class ***/
template<std::size_t size>
class Generic
@Sam-Belliveau
Sam-Belliveau / SPGL.hpp
Last active September 12, 2018 01:38
Sam's Pixel Graphics Library. TODO: detect key inputs
#ifndef SPGL_HPP
#define SPGL_HPP 1
#include <cstdint> // Fixed Length Ints
#include <array> // std::array
#include <SDL.h> // Graphics
namespace SPGL
{
#ifndef BIGINT_HPP
#define BIGINT_HPP
#include <bitset> // std::bitset
#include <cstdint> // std::size_t
namespace Big
{
template<std::size_t bits>
class Int
@Sam-Belliveau
Sam-Belliveau / SimpleTime.hpp
Last active May 4, 2019 19:18
A Chrono Wrapper
/* MIT License
* Copyright (c) 2018 Sam R. Belliveau
*
* 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 Software is
* furnished to do so, subject to the following conditions:
*
#ifndef EXAMPLE_SORTING_ALGORITHMS_HPP
#define EXAMPLE_SORTING_ALGORITHMS_HPP
#include <array>
// std::array - Used to pass arrays
#include <algorithm>
// std::swap - Used to swap data
#include <functional>