Skip to content

Instantly share code, notes, and snippets.

@digital-synapse
digital-synapse / train.js
Created March 12, 2021 00:47
simple image upscaling neural net
async function train(trainingPath)
{
const training = await getTrainingDataInBatches(trainingPath);
let model;
if (training[0].index > 0){
model = await tf.loadLayersModel(`file://./training/${training[0].index-1}/model.json`);
}
else {
@digital-synapse
digital-synapse / game_loop.cpp
Last active August 21, 2022 15:36
multi-threaded game loop in c++
int main(int argc, char* argv[])
{
if (!init()) return 1;
world.load();
player.load();
// launch game logic loop on a seperate thread
// this will handle update logic, animations, collision detection, etc
// and will run on a seperate CPU core than the main UI thread
@digital-synapse
digital-synapse / espresso-test.ino
Created March 17, 2019 15:49
test sketch for the espresso library
/*
Name: espresso_test.ino
Created: 3/15/2019 8:21:00 PM
Author: dss
*/
#include <espresso.h>
void setup() {
espresso_setup();
@digital-synapse
digital-synapse / darktheme.css
Created September 5, 2018 05:22
simple dark theme css for markdown
@import 'https://fonts.googleapis.com/css?family=Open+Sans';
body {
font-family: 'Open Sans', sans-serif;
line-height: 1.75em;
font-size: 16px;
background-color: #222;
color: #aaa;
padding: 15px;
}
@digital-synapse
digital-synapse / DataCube.cs
Created August 27, 2018 21:58
Fast 3D arrays in .Net
public class DataCube<T> {
public DataCube(int width, int height, int depth){
this.width = width;
this.height = height;
this.depth = depth;
size3d = width*height*depth;
size2d = width*height;
data = new T[size3d];
}
@digital-synapse
digital-synapse / Allocate.cs
Created August 24, 2018 17:55
Helper method for fast multi-dimentional arrays
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class Allocate
{
public static T[][][] Array3D<T>(int width, int height, int depth)
{
@digital-synapse
digital-synapse / IDontKnow.cs
Created July 20, 2018 22:00
Implement when you are not sure which interface to use
/// <summary>
/// Implement when you are not sure which interface to use
/// </summary>
public interface IDontKnow
{
}
@digital-synapse
digital-synapse / ComponentBase.cs
Created December 9, 2017 03:27
Unity base component for fast communication
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
/// <summary>
/// Base Component Class - Allows declaration of any component with a listener interface
/// </summary>
/// <typeparam name="TListenerInterface"></typeparam>