Skip to content

Instantly share code, notes, and snippets.

View efruchter's full-sized avatar
🏠
Working from home

Eric Fruchter efruchter

🏠
Working from home
  • Epic Games
  • Los Angeles, CA
View GitHub Profile
@efruchter
efruchter / ArrayRingBuffer.cs
Last active April 28, 2017 18:45
Fixed-size array ring buffer that allows direct access to underlying array if needed.
/// <summary>
/// An array-based ring buffer. The internal array can be accessed directly if needed.
/// </summary>
public class ArrayRingBuffer<T> : IEnumerable<T> {
public readonly T[] array;
private int startingIndex = 0;
private int count;
public ArrayRingBuffer(int size, T defaultValue) {
array = new T[size];
@efruchter
efruchter / linkz.cpp
Created September 29, 2017 07:17
Great repo of common c++ classes.
https://sites.google.com/site/indy256/algo_cpp/bigint
@efruchter
efruchter / targeting.m
Last active October 8, 2017 21:11
Complex numerical solution for a simple geometry problem
pkg load linear-algebra
# Initial Conditions
pc = [2,3]; #target pos
pb = [12,-2]; #bullet pos
vc = [7,3].*(1/3); #target vel
sb = 2.8480; #bullet speed
tolerance = 0.1; #search tolerance
# Routines
@efruchter
efruchter / ServiceLocator.cs
Last active January 2, 2019 20:01
My service locator plus injector boilercode. Requires C#7 for some syntax sugar, but can be backported.
namespace Common
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;
public static class ServiceLocator
{
@efruchter
efruchter / KMeans.cs
Last active March 1, 2019 01:19
Very basic KMeans in C#
public static int[] KMeansCluster(int clusterCount, float3[] data, int maxIterations = 1000)
{
if (clusterCount <= 0)
{
return new int[0];
}
int[] countWithinClusters = new int[clusterCount];
countWithinClusters.Fill(0);
@efruchter
efruchter / UnrealLearning.md
Last active January 14, 2019 07:09
Unreal Engine Links
@efruchter
efruchter / oats_containers.h
Created January 28, 2019 09:52
cheap containers. fixed-width buffers. asserts for bounds checks.
#pragma once
#include <assert.h>
namespace oats {
template <class T>
struct dynamic_array {
T * arr;
dynamic_array();
dynamic_array(const int initial_capacity);
~dynamic_array();
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Vertex Colors Only" {
Properties{
}
SubShader{
Tags { "RenderType" = "Opaque" }
LOD 200
@efruchter
efruchter / 1_split-costs.cpp
Last active July 9, 2019 05:11
Load data file with info about who stayed on what night, and distribute a cost among everyone.
#include <iostream>
#include <fstream>
#include <string>
// convert 2D coordinates to 1D array index
int flat_idx(const int row, const int col, const int row_length)
{
return (row * row_length) + col;
}
@efruchter
efruchter / .profile
Created August 31, 2019 23:21
Swap ESC and CAPSLOCK on a typical ubuntu system
/usr/bin/setxkbmap -option "caps:swapescape"