Skip to content

Instantly share code, notes, and snippets.

View danielytics's full-sized avatar
🚰

Dan Kersten danielytics

🚰
  • Dublin, Ireland
View GitHub Profile
@danielytics
danielytics / player.hpp
Last active March 19, 2018 17:12
Code snippets for "Using C++ and GDNative in Godot 3" tutorial, Part 2
#include <core/Godot.hpp>
#include <KinematicBody2D.hpp>
using namespace godot;
class Player : public GodotScript<KinematicBody2D>
{
public:
GODOT_SUBCLASS(Player, KinematicBody2D)
lock = RWLock()
with lock.read():
# Do some stuff
# Other threads can also use lock.read() at the same time, but no threads can lock.write() until current reads complete
with lock.write():
# Do some stuff
# No other thread can be reading or writing while this thread has the lock
@danielytics
danielytics / keybase.md
Created December 11, 2019 14:30
keybase.md

Keybase proof

I hereby claim:

  • I am danielytics on github.
  • I am guywithknife (https://keybase.io/guywithknife) on keybase.
  • I have a public key ASCfWEd74yrc1AWr28bUEd0t4hQWtWlaUtc7trWPJVU6two

To claim this, I am signing this object:

@danielytics
danielytics / glfw.cpp
Created February 14, 2021 19:48
OpenGL with SDL and GLFW
// Code taken from GLFW documentation: https://www.glfw.org/documentation.html
#include <GLFW/glfw3.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
@danielytics
danielytics / copy_entity.cpp
Created April 18, 2021 23:53
EnTT copy entity from one registry to another, from discord, saving for later
entt::entity EntityLayout::Build(entt::registry& reg, entt::hashed_string entName)
{
auto ConfigIt = g_entityConfigs.find(entName);
if (ConfigIt == g_entityConfigs.end())
{
return entt::null;
}
const EntityConfig& config = (*ConfigIt).second;
if (config.protoEnt_ == entt::null)
{
@danielytics
danielytics / also_working.cpp
Created June 8, 2021 15:49
EnTT poly_storage registry copying
#include <iostream>
#include <entt/entity/registry.hpp>
struct A {
};
struct B {
int x;

Compile with:

clang++ -std=c++11 main.cpp -o assignment

Compile tests with:

clang++ -std=c++11 main.cpp -o assignment -DTESTS

Run with:

@danielytics
danielytics / benchmark.cpp
Last active August 27, 2021 02:57
std::regex benchmark
#include <string>
#include <regex>
#include <iostream>
#include <random>
#include <vector>
#include "plf_nanotimer.h"
bool find_regex (const std::string& input)
@danielytics
danielytics / frame_buttons.txt
Created September 27, 2021 11:31
UGEE M708 V2 raw input samples
003:014:002:STREAM 1632742116.042551
02 F0 01 00 00 00 00 00 00 00 00 00
003:014:002:STREAM 1632742116.278540
02 F0 00 00 00 00 00 00 00 00 00 00
003:014:002:STREAM 1632742117.102424
02 F0 02 00 00 00 00 00 00 00 00 00
003:014:002:STREAM 1632742117.342543
@danielytics
danielytics / entt_polystorage.hpp
Created March 28, 2022 14:52
entt polystorage based registry and entity copy
#pragma once
#include <entt/core/utility.hpp>
#include <entt/entity/poly_storage.hpp>
#include <cstring>
enum OnComponentCollision {
Replace,
Skip,
};