Skip to content

Instantly share code, notes, and snippets.

View mattearly's full-sized avatar

Matthew Early mattearly

View GitHub Profile
@mattearly
mattearly / sdl2_opengl.cpp
Last active August 17, 2020 22:22 — forked from jordandee/sdl2_opengl.cpp
Simple SDL2/OpenGL example
// To compile with gcc: (tested on Ubuntu 14.04 64bit):
// g++ sdl2_opengl.cpp -lSDL2main -lSDL2 -lGL
// To compile with msvc: (tested on Windows 7 64bit)
// cl sdl2_opengl.cpp /I C:\sdl2path\include /link C:\path\SDL2.lib C:\path\SDL2main.lib /SUBSYSTEM:CONSOLE /NODEFAULTLIB:libcmtd.lib opengl32.lib
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
@mattearly
mattearly / mult_choice_question.tex
Created January 28, 2018 17:25
Basic LaTeX Question and Answer Multiple Choice Example
\documentclass[11pt]{article}
\begin{document}
\section{Question}
a. thing \\
b. thing \\
c. thing \\
d. thing
\section{Question}
<resources>
<string-array name="sport_select">
<item>"American Footbal"</item>
<item>"Archery"</item>
<item>"Badminton"</item>
<item>"Baseball"</item>
<item>"Basketball"</item>
<item>"Beach Volleyball"</item>
<item>"Bowling"</item>
sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libsdl2-gfx-dev libsdl2-net-dev
// counts to the number provided with even numbers using a recursive recursive algo
// written by Matthew Early, but hey this is a pretty common practice problem
// default compile:
// compile in terminal with 'g++ recursive-even-counter.cpp'
// run with './a.out' in terminal
#include <iostream>
#include <cstdlib>
using namespace std;
; extra all list elements in a list
(define (extract-list lst)
(cond ((null? lst) lst)
((list? (car lst)) (cons (car lst) (extract-lists (cdr lst))))
(else (extract-list (cdr lst))
)
)
; return number of even integers
(defin (count-even lst)
@mattearly
mattearly / findString_noCase.h
Created April 16, 2017 00:38
function for searching without caring about case matching
#include <string>
#include <cctype>
bool findStringIC(const std::string & strHaystack, const std::string & strNeedle) {
auto it = std::search(
strHaystack.begin(), strHaystack.end(),
strNeedle.begin(), strNeedle.end(),
[](char ch1, char ch2) { return std::tolower(ch1) == std::tolower(ch2); }
);
return (it != strHaystack.end() );
@mattearly
mattearly / split.h
Created April 16, 2017 00:36
python-like split for c++
#pragma once
#include <string>
#include <sstream>
#include <vector>
#include <iterator>
// split function for c++ -- from http://stackoverflow.com/questions/236129/split-a-string-in-c
template<typename Out>
@mattearly
mattearly / trim.h
Created April 16, 2017 00:35
python-like trim for c++
#pragma once
#include <string>
//because other langauges have these and the c++ does not
//Trims whitespace - from http://stackoverflow.com/questions/1798112/removing-leading-and-trailing-spaces-from-a-string
std::string trim(const std::string& str,
const std::string& whitespace = " \t")
{
const auto strBegin = str.find_first_not_of(whitespace);
(*find i within the lst*)
let rec member i lst =
match lst with
[] -> false
| hd::tl -> hd = i || member i tl;;
(*with if else instead*)