Skip to content

Instantly share code, notes, and snippets.

Avatar

Jay Bazuzi JayBazuzi

View GitHub Profile
@JayBazuzi
JayBazuzi / setup.ps1
Last active Jul 20, 2020
New machine setup for mobbing
View setup.ps1
# To run this script directly, run this in an elevated admin PowerShell prompt:
# Invoke-WebRequest -UseBasicParsing https://gist.githubusercontent.com/JayBazuzi/296db9c7ecc15dad0f12287293b11125/raw/setup.ps1 | Invoke-Expression
iwr -useb cin.st | iex
choco feature enable --name=allowGlobalConfirmation
cinst vscode win-no-annoy googlechrome
cinst poshgit git github-desktop
cinst notepadplusplus beyondcompare
cinst visualstudio2019professional visualstudio2019-workload-manageddesktop netfx-4.8-devpack
cinst resharper-ultimate-all ncrunch-vs2019
View _original_inverse_square_root.c
float Q_rsqrt_original(float number)
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = *(long*)&y; // evil floating point bit level hacking
i = 0x5f3759df - (i >> 1); // what the fuck?
View best peanut butter and jelly.cs
var zipCodePipe = new InputPipe<ZipCode>("zipCode");
var peanutButtersPipe = zipCodePipe.ProcessFunction( PeanutButterShop.GetAvailable);
var jelliesPipe = zipCodePipe.ProcessFunction(JellyShop.GetAvailable);
var bestPeanutButterPipe = peanutButtersPipe.Process(_ => _.BestPeanutButter);
var bestJelliesPipe = jelliesPipe.Process(_ => _.BestJelly);
var joinedPipe = bestPeanutButterPipe.JoinTo(bestJelliesPipe);
var sandwichPipe = joinedPipe.Process((bestPeanutButter, bestJelly) =>
Sandwich.Create(bestPeanutButter, bestJelly));
sandwichPipe.Collect();
View You can add to an array the same way you can add to a list.cpp
#include "okra.h"
TEST("addToArray will result in a new copy of the array with the added items")
{
const vector<int> numbers = {1, 2, 3};
const vector<int> result = ArrayUtils::addtoArray(numbers, 4, 5, 6);
assertArrayEquals(vector<int>{1, 2, 3, 4, 5, 6}, result);
}
View addToArrayTest.java
@Test
class YouCanAddToAnArrayTheSameWayYouCanAddToAList
{
public void addToArray_WillResultInANewCopyOfTheArrayWithTheAddedItems() throws Exception
{
Integer[] numbers = {1, 2, 3};
Integer[] result = ArrayUtils.addtoArray(numbers, 4, 5, 6);
assertArrayEquals({1, 2, 3, 4, 5, 6}, result);
}
}
View LegacyCharExampleSyntax.cs
//
// - PipeSource is split. The "take a static input" is one part. The "execute a function and broadcast the result" is another.
//
// - A FunctionPipe is like PipeMiddle, with the specific purpose of applying an A->B function to each item in the pipeline. Its last ctor parameter is the thing it listens to. (Assume it calls `predecessor.AndNext(this)`)
//
// - An overloaded FunctionPipe ctor takes a string, to identify it in the ASCII art, when the function is a lambda that doesn't have a friendly name.
// var characterFile = CharacterFile.From(fileName);
var fileNamePipe = StaticInputPipe.Of(fileName);
var characterFile = FunctionPipe.Of(CharacterFile.From, fileNamePipe);
@JayBazuzi
JayBazuzi / LegacyCharExampleSyntax.cs
Created Feb 19, 2019
- PipeSource is split into a StaticInputPipe and a PipeMiddle
View LegacyCharExampleSyntax.cs
// var characterFile = CharacterFile.From(fileName);
var fileName = new StaticInputPipe(fileName);
var characterFile = new FunctionPipe(CharacterFile.From, fileName);
// var configFile = ConfigFile.Matching(characterFile);
var configFile = new FunctionPipe(ConfigFile.Matching, characterFile);
// var partialCards = characterFile.ParseCards();
var partialCards = new FunctionPipe("CharacterFile.ParseCards", _ => _.ParseCards(), characterFile);
@JayBazuzi
JayBazuzi / LegacyCharExampleSyntax.cs
Created Feb 19, 2019
- PipeSource is split into a StaticInputPipe and a PipeMiddle
View LegacyCharExampleSyntax.cs
// var characterFile = CharacterFile.From(fileName);
var fileName = new StaticInputPipe(fileName);
var characterFile = new FunctionPipe(CharacterFile.From, fileName);
// var configFile = ConfigFile.Matching(characterFile);
var configFile = new FunctionPipe(ConfigFile.Matching, characterFile);
// var partialCards = characterFile.ParseCards();
var partialCards = new FunctionPipe("CharacterFile.ParseCards", _ => _.ParseCards(), characterFile);
View DoEverything.cpp
CharacterData MakeAllTheViewModels(
const std::string& fileName, const std::string& username, const std::string& password)
{
auto characterFile = CharacterFile::From(fileName);
auto configFile = ConfigFile::Matching(characterFile);
auto partialCards = characterFile.ParseCards();
auto localCards = configFile.ParseCards();
auto compendiumService = CompendiumService::Authenticate(username, password);
auto cardService = CardService::Authenticate(username, password);
View IniitalizePipeline.cs
var pipeline = new Pipeline(CharacterFile.From)
{
new ResultCollector<CharacterFile>(),
new Pipeline(ConfigFile.Matching)
{
new ResultCollector<ConfigFile>(),
},
new Pipeline(_ => _.ParseCards())
{
new ResultCollector<List<CardData>>(),
You can’t perform that action at this time.