Skip to content

Instantly share code, notes, and snippets.

💭
"Continuous effort is the key to unlocking our potential."

Chris Ohk utilForever

💭
"Continuous effort is the key to unlocking our potential."
Block or report user

Report or block utilForever

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@utilForever
utilForever / TriangleMesh.cpp
Created Aug 19, 2019
Create PxShape using PxTriangleMesh
View TriangleMesh.cpp
physx::PxVec3* pPxVerts = new physx::PxVec3[list.vertexCount];
for (int i = 0; i < list.vertexCount; i++)
{
ConvertPosToPhysX(list.pVerts[i], pPxVerts[i]);
}
physx::PxU32* pPxIndices = new physx::PxU32[list.triangleCount * 3];
for (int i = 0; i < list.triangleCount * 3; ++i)
@utilForever
utilForever / localtime.hpp
Created Jun 16, 2019
Comparison between localtime_r and localtime_s
View localtime.hpp
#include <ctime>
#include <iostream>
int is_morning_good() {
const time_t now_seconds = time(NULL);
struct tm now;
localtime_r(&now_seconds, &now);
return (now.tm_hour < 12);
}
@utilForever
utilForever / RandomPolicyTest.cpp
Created May 9, 2019
RosettaStone - Random policy test
View RandomPolicyTest.cpp
TEST(RandomPolicy, Mulligan)
{
for (int i = 0; i < 100; ++i)
{
GameConfig config;
config.player1Class = CardClass::ROGUE;
config.player2Class = CardClass::PALADIN;
config.startPlayer = PlayerType::RANDOM;
config.doShuffle = false;
config.doFillDecks = false;
@utilForever
utilForever / func_timeout.cpp
Last active Apr 13, 2019
Timeout function example
View func_timeout.cpp
#include <chrono>
#include <condition_variable>
#include <iostream>
#include <mutex>
#include <thread>
using namespace std::chrono_literals;
int Func()
{
View RegexTest.cpp
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <regex>
int main()
{
std::regex attackRegex("\\+([[:digit:]]+) Attack");
std::string text = "Raid Leader is granting this minion +1 Attack";
std::smatch values;
@utilForever
utilForever / GraphTest.cpp
Created Feb 12, 2019
CubbyDNN graph sample code
View GraphTest.cpp
using Tensor = Tensor<float>;
Graph g;
auto& input = g.Input(TensorShape(64, 32));
auto& oneHot = g.Reshape(input, TensorShape(1, 2048));
auto& output = g.DropOut(oneHot, 10);
auto& answer = g.Max(result);
for (int i = 0; i < trainNum; ++i)
{
@utilForever
utilForever / overload.cpp
Last active Sep 28, 2018
C++17 overload pattern with std::variant and std::visit (https://www.bfilipek.com/2018/09/visit-variants.html)
View overload.cpp
#include <iostream>
#include <variant>
struct Fluid { };
struct LightItem { };
struct HeavyItem { };
struct FragileItem { };
struct GlassBox { };
struct CardboardBox { };
@utilForever
utilForever / Rand.cpp
Created Sep 19, 2018
Simple Rand class to roll dice.
View Rand.cpp
#include <random>
#include <iostream>
class Rand
{
public:
Rand()
{
m_generator.seed(m_device());
@utilForever
utilForever / ParseValueRangeFromString.cpp
Last active May 18, 2018
Parse value range from std::string (For example, parse 10 or 10-19 only)
View ParseValueRangeFromString.cpp
inline std::tuple<size_t, size_t> ParseValueRangeFromString(std::string str,
bool& isValid)
{
std::regex reValueRange("([[:digit:]]+)(-[[:digit:]]+)?");
std::smatch values;
size_t minValue = 0, maxValue = std::numeric_limits<size_t>::max();
if (!str.empty())
{
if (std::regex_match(str, values, reValueRange))
@utilForever
utilForever / Enums.h
Created May 11, 2018
VS compatible better-enums
View Enums.h
/*************************************************************************
> File Name: Enums.h
> Project Name: Hearthstone++
> Author: Chan-Ho Chris Ohk
> Purpose: Enumerations for card data.
> Created Time: 2017/08/11
> Copyright (c) 2017, Chan-Ho Chris Ohk
*************************************************************************/
#ifndef HEARTHSTONEPP_ENUMS_H
#define HEARTHSTONEPP_ENUMS_H
You can’t perform that action at this time.