Skip to content

Instantly share code, notes, and snippets.

Avatar

Jay Bazuzi JayBazuzi

View GitHub Profile
@JayBazuzi
JayBazuzi / gist:978c5a2e3262e66f33ff158c7c26f73a
Created Jun 9, 2021
Arlo's Commit Notation push rule regex
View gist:978c5a2e3262e66f33ff158c7c26f73a
# I'm experimenting with a GitLab Push Rule to force all commits to follow Arlo's Commit Notation. Here's my latest regex:
^([RFB]!!)|([RFBa-z] )|(\*\*\*)[- ].*
@JayBazuzi
JayBazuzi / Pipelines.py
Last active Sep 12, 2020
Pipelines in Python proof-of-concept
View Pipelines.py
# /usr/bin/env python3
from typing import Callable
import unittest
import typing
import abc
import typing
class Tests(unittest.TestCase):
@JayBazuzi
JayBazuzi / setup.ps1
Last active Sep 19, 2020
New machine setup for mobbing
View setup.ps1
# Moved!
iwr -useb https://raw.githubusercontent.com/refactoring-pipelines/Pipelines/master/machine-setup.ps1 | iex
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);