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 / 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 / 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 / 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 / Snake.cpp
Created February 27, 2017 02:21
A 1-script snake game implemented in object-less c++
// Snake.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <Windows.h>
using namespace std;
@efruchter
efruchter / radix_sort_test.cpp
Last active January 14, 2016 14:43
radix-sort for 32-bit 2's-compliment integers. Implemented a homegrown clone of of std's stable_partition.
#include <iostream>
#include <functional>
#include <iterator>
#include <vector>
struct Node {
Node* next = nullptr;
int data;
};
@efruchter
efruchter / Trie.cpp
Last active January 14, 2016 14:52
fast hashset for character arrays.
//
// Trie.cpp
// CPPTest
//
// Created by Eric Fruchter on 12/26/15.
// Copyright © 2015 Eric Fruchter. All rights reserved.
//
#include "Trie.hpp"
@efruchter
efruchter / Trie.cs
Last active April 22, 2018 21:35
A Trie implementation in C#
using System;
using System.Collections.Generic;
/**
* A space-saving data structure to store words and their counts.
* Words that share prefixes will have common paths along a branch of the tree.
*/
public class Trie
{
private TrieNode head;
@efruchter
efruchter / secretshader.shader
Last active August 29, 2015 14:18
cuts two alpha holes in a texture.
Shader "Expiremental/CircleCutout"
{
Properties
{
[PerRendererData] x1 ("1.x", Float) = 0
[PerRendererData] y1 ("1.y", Float) = 0
[PerRendererData] x2 ("2.x", Float) = 0
[PerRendererData] y2 ("2.y", Float) = 0
@efruchter
efruchter / RenderTextureInNewTabExample.cs
Last active August 29, 2015 14:17
Open a texture from Unity3D Web player in another tab of the web browser.
using UnityEngine;
using System.Collections;
using System.Text;
public class RenderTextureInNewTabExample : MonoBehaviour
{
public Texture2D texture;
void Start ()
{
@efruchter
efruchter / markov_ride.py
Last active August 29, 2015 14:12
MC Ride Trigrams. Enjoy the soothing verse of MC Ride from the comfort of your own computer.
from nltk.util import ngrams
from nltk.model import NgramModel
from nltk.probability import LidstoneProbDist
# Source: should be formatted on multiple lines for each sentence.
SOURCE_TEXT = 'Mystery.txt'
LINE_START = "<line>"
LINE_END = "</line>"