Skip to content

Instantly share code, notes, and snippets.

View Kaminate's full-sized avatar
🙃
Killin' it

白★能盛 Kaminate

🙃
Killin' it
  • United States
View GitHub Profile
@Kaminate
Kaminate / pay_respects.cpp
Last active September 21, 2023 05:06
Press F to pay respects
#ifdef _WIN32
#include <conio.h> // _getch
#include <ctype.h> // toupper
#include <stdio.h> // printf
int main(int argc, char** )
{
printf( "Press F to pay respects: " );
for( ;; )
{
@Kaminate
Kaminate / variadic_specialization.cpp
Last active March 31, 2016 02:36
Call functions with differently ordered arguments using template specialization, c++11 variadic templates, and <utility>'s std::forward. g++ variadic_specialization.cpp -otest.exe -std=c++11
#include <utility> // std::forward
template< typename T, typename... Args >
void SetValues( T* t, Args&&... args ) {
SetValues( t );
SetValues( std::forward< Args >( args )... );
}
template<> void SetValues< int >( int *p ) { *p = 69; }
template<> void SetValues< float >( float* p ) { *p = 3.14f; }
#include <iostream> // std::cout, std::endl
@Kaminate
Kaminate / ShaderPixels.v.glsl
Last active March 25, 2016 22:48
Shader storage buffer
#version 430
in vec4 vColor;
out vec4 outColor;
void main()
{
outColor = vColor;
}
@Kaminate
Kaminate / MemoryManager.cpp
Created August 6, 2013 06:36
Just the implementation of some c style memory manager functions
/*!
Memory Manager
Nathan Park
*/
#include "MemoryManager.h"
// #include <new.h> placement new
@Kaminate
Kaminate / PB_perlin..h
Created August 6, 2013 06:29
Perlin Noise. Justin wrote this, I haven't actually looked at it yet... ANSI C
#ifndef PB_PERLIN_H
#define PB_PERLIN_H
#include "PB_geom.h"
#include "PB_texture.h"
#include <stdlib.h>
#include <math.h>
typedef struct PerlinNoise
{
/******************************************************************************
File: PB_gjk.c
Description: this file contains the functions for collision detection using
the gjk algorithm.
******************************************************************************/
#include "PB_gjk.h"
#include "PB_n8math.h" //vector math operations
#include "PB_physics_debug_draw.h" //debug draw purposes
@Kaminate
Kaminate / BloodAlcoholConcentration.cpp
Created August 6, 2013 06:12
Describes a person and (alcoholic) drink class. When a person drinks a drink, it takes the timestamp into account when calculating the person's BAC (blood alcohol concentration). I made this for 2013 Angelhack in Seattle.
// 2013 Nathan Park
// Angelhack in Seattle
#include <iostream>
#include <string>
#include <vector>
typedef float Date;
const float grams_per_lb = 453.592f;
const float lbs_per_gram = 1.0f / grams_per_lb;
@Kaminate
Kaminate / NumberOfPrimes
Created August 6, 2013 06:10
Returns the number of primes before int N. This is my implementation of a programming internship practice test problem from some game company. I used the sieve of eratosthenes I saw on wiki once.
// Nathan Park
//
// This is my implementation of a programming intership practice test problem
// from some company.
#include <vector>
int getNumberOfPrimes(int N)
{
std:vector <int> primes(N, 1); // 0 = prime, 1 means not prime
@Kaminate
Kaminate / HowSphericalCoordinatesWork.txt
Created August 6, 2013 06:07
How Spherical Coordinates work (no pictures, sorry)
say you have a coordinate system
x axis
y axis
z axis
and a vector v
if you think of the coordinates as a vector (say x) and a plane (say yz)
v makes a half-angle alpha [0,180] with x
@Kaminate
Kaminate / Array2D.h
Created August 6, 2013 06:06
2D dynamic array wrapper. Allocates memory in the constructor, deallocates memory in the destructor. Everything is inline, so it can be used as a header-only (library?).
////////////////////
// Nathan Park //
// August 3, 2013 //
////////////////////
#ifndef __ARRAY2D_H_
#define __ARRAY2D_H_
#include <iostream>
#include <iomanip>