Skip to content

Instantly share code, notes, and snippets.

View CAD97's full-sized avatar

Christopher Durham CAD97

View GitHub Profile
package com.cad97.spawnercraft;
import net.minecraft.block.BlockMobSpawner;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@CAD97
CAD97 / NumberWizard.cs
Created May 13, 2015 16:55
My implementation of the NumberWizard game from the Udemy Unitycourse
using UnityEngine;
using System.Collections;
public class NumberWizard : MonoBehaviour {
int max;
int min;
int guess;
void Start () {
@CAD97
CAD97 / TextController.cs
Created May 15, 2015 12:28
My implementation of the Udemy Unity Course "Text101" game.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class TextController : MonoBehaviour {
#region Unity editor fields
[SerializeField]
private State startingState;
#endregion
@CAD97
CAD97 / Notes.md
Created September 8, 2015 16:56
Custom low hertz clock in Minecraft

First, let me explain the syntax I've used above. REPEAT/CHAIN/(IM)PULSE should be self explaining. The commands following are what's in the cmd block. Indent of a block means that it's chaining from previous.

BLOCK means it is conditional on the previous block in the chain.

The test score is the number of ticks between pulses. You could make it a score of its own for on-the-fly editing. !IMPORTANT! Make sure that the IMPULSE block is {auto:0b} when you leave it, otherwise it won't trigger again (as it's an impulse.)

I think as an idiom, if line is meant to be pulsed once, then rest a number of ticks, then it should be pulsed by an IMPULSE.

@CAD97
CAD97 / BetterInput.cs
Last active January 23, 2016 20:32
Better input for Unity C#
using System;
using UnityEngine;
namespace cad97.BetterInput
{
public class Smart2DInput
{
public static float Deadzone { get; set; }
public static JoystickDeadzoneStyle DeadzoneStyle { get; set; }
@CAD97
CAD97 / _explain.md
Last active February 9, 2016 03:02
Fibonacci algorithms

For my current Computer Science class, our teacher gave us the Java algorithm fib(int n) and told us to replicate it in MIPS assembly. I thought I could do a better algorithm, and thus, I created ofib(int n) in MIPS assembly and created a Java version as well.

If my calculations are correct, the provided fib takes n*7 instructions to calculate the nth Fibonacci number (with my MIPS translation anyway: I tried my best to optimize the assembly within the algorithm), where my ofib takes n*5 instructions (and I'm pretty sure that this is the best implementation of this algorithm as I optimized it for the assembly level directly).

I would not have been able to write ofib without the insight optimizing fib gave me. As such I understand why fib was given as the example, as its algorithm is easier to follow. However, I wanted to go deeper optization.

This was done as a fun exercise. I don't know if this is the best algorithm, or even if it has any gain in a high-level world, but I had fun seeing ho

@CAD97
CAD97 / _about.md
Last active June 1, 2020 16:50
Python script to use ffmpeg to split mp4 with a video stream and three audio streams into component parts

Why

I use OBS to record and stream, and it allows me to record multiple audio streams to the output container (.mp4). The advantage to doing this is that in post-production (for the recordings) I can then adjust the relative volumes of the differing streams if the balance wasn't perfect in recording. Thus, I'm recording a mixed track 1, my voice only to track 2, and my computer sound out to track 3. (Streaming only takes one track.)

Unfortunately, my editing software (Adobe Premiere Elements 12) doesn't handle multiple audio streams on a .mp4 container. Thus, before I can benefit from having the multiple streams, I need to seperate them out of their container.

The same goes for using Audacity; if I want to mix the separate tracks together using audio editing software, I need to detatch it from the video first.

Thankfully, ffmpeg, which I already had installed, can accomplish this task very easily. It was just a matter of looking up the exact command to split the streams from the input file to seper

@CAD97
CAD97 / main.swift
Created July 30, 2016 01:11
Swift removeFirst/Last micro benchmark
//
// main.swift
// microbenchmark
//
// Created by Christopher Durham on 7/29/16.
// Copyright © 2016 Christopher Durham. All rights reserved.
//
import Foundation
@CAD97
CAD97 / main.swift
Created July 30, 2016 01:54
Swift AnyIterator micro benchmark
//
// main.swift
// microbenchmark
//
// Created by Christopher Durham on 7/29/16.
// Copyright © 2016 Christopher Durham. All rights reserved.
//
import Foundation
@CAD97
CAD97 / Unicode.g4
Created August 22, 2016 19:10
Unicode character class fragments for ANTLR
// Generated by scripts/gen_fragment.py
lexer grammar Unicode;
// [C] Other
fragment C : Cc | Cf | /* Cn | Co | Cs */ ;
// [Cc] Other, Control
fragment Cc : '\u0000'..'\u001F' | '\u007F'..'\u009F' ;