Skip to content

Instantly share code, notes, and snippets.

View miguelmartin75's full-sized avatar

Miguel Martin miguelmartin75

View GitHub Profile
@miguelmartin75
miguelmartin75 / insertion_sort.cpp
Last active August 29, 2015 14:03
sorting algorithms, heh.
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
template <typename RandomIt>
void insertion_sort(RandomIt begin, RandomIt end)
{
// loop through all the elements, from
// the the second element to the last.
@miguelmartin75
miguelmartin75 / intostr.cpp
Last active August 29, 2015 14:02
add vs lookup table
#include <chrono>
#include <cstdint>
#include <iostream>
#include <random>
#include <sstream>
using namespace std;
typedef std::chrono::microseconds time_unit;
static const std::string time_unit_suffix{"us"};
import random
HEADS = 0
TAILS = 1
n = input("How many samples do you wish to compute?: ")
p = random.random()
print "probability of getting heads is:", p
@miguelmartin75
miguelmartin75 / rojo_design.cpp
Last active January 2, 2016 19:29
A design for my library rojo (the rendering aspect of it).
struct ogl_backend
{
typedef unsigned texture_handle_type;
void load(texture_handle_type& texture, const Image& image)
{
std::cout << "loading, " << image.id << '\n';
}
void destroy(texture_handle_type& texture)
@miguelmartin75
miguelmartin75 / SDL.cpp
Last active September 22, 2024 22:53
A simple application with SDL (1.2 and 2), to check whether it is working or not.
#include <iostream>
#include <SDL/SDL.h>
int main(int argc, char * argv[])
{
// Initialize SDL with video
SDL_Init(SDL_INIT_VIDEO);
// Create a window with SDL