Skip to content

Instantly share code, notes, and snippets.

View CAD97's full-sized avatar

Crystal Durham CAD97

View GitHub Profile
@CAD97
CAD97 / README.md
Created April 20, 2018 22:51
I made a lazy slog

This is a potential crate that would simplify the use of the example-lib pattern for slog.

The motivation is the same as that of the example-lib: a library using slog for its logging would like to accept a parent logger if the crate pulling it in is using slog, or fall back to interfacing with log's static logger if not.

At any entry point to your library's interface, you would retrieve the Logger from your lazy slog. After that point, you would pass it around and create child loggers like normal.

<?import javafx.scene.control.TextField?>
<?import tornadofx.Field?>
<?import tornadofx.Fieldset?>
<?import tornadofx.Form?>
<Form xmlns="http://javafx.com/javafx/null" xmlns:fx="http://javafx.com/fxml/1">
<Fieldset>
<!--Field text=""-->
<Field>
<TextField/>
</Field>
@CAD97
CAD97 / antlrbug.zip
Last active January 10, 2017 02:50
antlr/intellij-plugin-v4 disagrees with antlr/antlr4/antlr4-maven-plugin/ on `.tokens` location
@CAD97
CAD97 / Animator.java
Last active December 9, 2016 15:41
Animation Test
import javax.swing.*;
import java.awt.*;
import java.awt.geom.Area;
import java.util.List;
/**
* Animate Polygons around on a Graphics object.
*
* @author Christopher Durham
* @date 11/25/2016
@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' ;
@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 / 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 / _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 / _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 / 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; }