Skip to content

Instantly share code, notes, and snippets.

View hamsham's full-sized avatar

Miles Lacey hamsham

View GitHub Profile
@hamsham
hamsham / token.cpp
Created April 5, 2014 21:43
Skeleton code for a command-Line argument tokenizer. It will input command-line arguments, convert them into a native data type, and place them into an std::vector as tuples.
/**
* Simple string-to-type tokenizing.
* This program can be used as skeleton code for creating a tokenizer for
* command-line arguments. It will convert values into a tuple-type where values
* can be extracted using their intended data type.
*
* Example:
* token +3.14159
* Results in two returned values:
@hamsham
hamsham / pluginAPI.h
Created November 3, 2014 03:19
An example API for an example plugin system in C++.
/**
* Plugin API header
*/
#ifndef __PLUGIN_API_H__
#define __PLUGIN_API_H__
/*
* Windows-specific settings for a dynamic library
*/
@hamsham
hamsham / sharedLibrary.h
Created November 3, 2014 03:22
Example header for a shared library loader that loads plugin objects from the pluginAPI.h header.
#ifndef __SHARED_LIB_H__
#define __SHARED_LIB_H__
#include <string>
#include "pluginAPI.h"
//-----------------------------------------------------------------------------
// Shared Library loading object (Used for RAII purposes).
@hamsham
hamsham / sharedLibrary.cpp
Last active August 29, 2015 14:08
Example source file for a shared library loader that loads plugin objects from the pluginAPI.h header
#include <iostream>
#include <string>
#include <cctype> // tolower()
#include <SDL2/SDL.h>
#include "sharedLibrary.h"
//-----------------------------------------------------------------------------
@hamsham
hamsham / pluginLoader.cpp
Created November 3, 2014 04:03
Main procedure for loading a plugin library at runtime.
/**
* A test of user-defined plugins
*
* g++ -std=c++11 -Wall -Wextra -Werror -pedantic -pedantic-errors -DSDL_MAIN_HANDLED main.cpp sharedLibrary.cpp -o PluginLoader -lSDL2
*/
#include <iostream> // std::cin, std::cout, std:: cerr
#include <vector>
#include <string>
/**
* Testing the plugin interface
* If you're using GCC/G++, specify the additional linker options:
*
* Indicate that this is a shared library:
* shared -s
*
* Use the provided directive to export compiler symbols to the shared library:
* -DBUILD_PLUGIN
@hamsham
hamsham / work_dispatch.cpp
Created November 18, 2014 09:08
An (incomplete) example in setting up a Worker/Dispatcher system in C++.
/**
* An (incomplete) example in setting up a Worker/Dispatcher system.
*
* g++ -std=c++11 -Wall -Werror -Wextra -pedantic -pedantic-errors work_dispatch.cpp -o work_dispatch
*/
#include <iostream>
#include <vector>
#include <unordered_map>
import QtQuick 2.4
Item {
id: thisCircle
property string color: "black"
property alias border: thisBorder
property real renderWidth: width
property real renderHeight: height
@hamsham
hamsham / cuda_math.h
Created August 18, 2015 06:26
Basic Linear Algebra functions for CUDA
#include <math.h>
__device__ inline float clampf(const float n, const float minVal, const float maxVal)
{
return (n < minVal ? minVal : n) > maxVal ? maxVal : n;
}
@hamsham
hamsham / sfml_music.cpp
Created November 15, 2015 08:15
A simple example of playing an audio file using SFML2
/**
* Testing the audio API in SFML
*
* g++ -std=c++11 -Wall -Werror -Wextra -pedantic-errors sfmusic.cpp -o sfmusic -lsfml-audio -lsfml-system
*/
#include <sys/stat.h>
#include <iostream>