Skip to content

Instantly share code, notes, and snippets.

View isidore's full-sized avatar

Llewellyn Falco isidore

View GitHub Profile
public static int calculateDamageForDice(Character atk, Character def, int dice)
{
boolean hits = def.getArmorClass() < atk.getForce() + dice;
if (hits && dice != 1)
{
int modifier = dice == 20 ? 2 : 1;
return atk.getWeaponDamage() * modifier;
}
else
{
import org.approvaltests.combinations.CombinationApprovals
import org.junit.jupiter.api.Test
import org.lambda.functions.Function2
class InlineTest {
@Test
internal fun testInline() {
val numbers = arrayOf(10, 20, 30, 40, 50)
CombinationApprovals.verifyAllCombinations(Combine(), numbers, numbers)
}
public class ProgrammableReporter : IEnvironmentAwareReporter
{
public static IEnvironmentAwareReporter PassTo { get; set; }
public void Report(string approved, string received)
{
PassTo.Report(approved, received);
}

Basic pipelines

Let's say you have the following line of code:

var _result = long.Parse(age);

snippet source

ArrayUtils.addToArray()

Sometimes you wish you could add to an array the same way you can add to a list.

Integer[] numbers = {1, 2, 3};
numbers = ArrayUtils.addToArray(numbers, 4, 5, 6);

will result in a new copy of the array with the added items

@Test
public void testAddManyToArray() throws Exception
{
Integer[] numbers = {1, 2, 3};
numbers = ArrayUtils.addToArray(numbers, 4, 5, 6);
Integer[] resulting = {1, 2, 3, 4, 5, 6};
assertArrayEquals(resulting, numbers);
}
#include "catch.hpp"
#include <iostream>
class BaseStructure
{
public:
void(*print)();
};
class One
@isidore
isidore / FizzBuzz.py
Created November 9, 2017 12:11
FizzBuzz Mob Solution from Agile Coaching DC Meetup
from unittest import TestCase
class FizzBuzz(object):
@classmethod
def convert(cls, param):
if (param % 3 == 0 and param % 5 ==0):
return str("FizzBuzz")
if (param % 3 == 0):
return str("Fizz")
from unittest import TestCase
def fizzbuzz(i):
#FIZZ when number 3
if i % 3 == 0 and i % 5 == 0:
return "FIZZBUZZ"
if i % 3 == 0:
return "FIZZ"
if i % 5 == 0:
@isidore
isidore / FizzBuzzTest.py
Created May 2, 2017 18:33
Code from GotoChicago 2017 Mob Programming Session
from unittest import TestCase
def fizzbuzz(number):
if number%15 ==0:
return "fizzbuzz"
if number %5 ==0:
return "buzz"
if number %3 ==0:
return "fizz"