Skip to content

Instantly share code, notes, and snippets.

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

Eric Fruchter efruchter

🏠
Working from home
View GitHub Profile
@efruchter
efruchter / BirthdayParadox.cpp
Created November 17, 2021 01:18
calculate the probabilities that a group of n people will have at least two people within that share the same birthday.
double CurProb = 1;
std::cout << 1 << ": " << 0.0 << std::endl;
for (int i = 1; i < 100; i++)
{
double bp = (365.0 - (double)i) / 365.0;
CurProb *= bp;
std::cout << (i + 1) << ": " << (1.0 - CurProb) << std::endl;
}
:nmap ; :
" tabstop: Width of tab character
" softtabstop: Fine tunes the amount of white space to be added
" shiftwidth Determines the amount of whitespace to add in normal mode
" expandtab: When on uses space instead of tabs
set tabstop =4
set softtabstop =4
set shiftwidth =4
set expandtab
set number
@efruchter
efruchter / bigsort.cpp
Last active October 7, 2019 00:27
dumb stuff
// Puts work into a buffer so it can handle larger collections than the naive stack versions
template <class T>
struct QSWork {
T* begins;
T* ends;
static QSWork Create( T* begins, T* ends ) {
QSWork work;
work.begins = begins;
work.ends = ends;
@efruchter
efruchter / .profile
Created August 31, 2019 23:21
Swap ESC and CAPSLOCK on a typical ubuntu system
/usr/bin/setxkbmap -option "caps:swapescape"
@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;
}
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Vertex Colors Only" {
Properties{
}
SubShader{
Tags { "RenderType" = "Opaque" }
LOD 200
@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();
@efruchter
efruchter / UnrealLearning.md
Last active January 14, 2019 07:09
Unreal Engine Links
@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 / 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
{