Skip to content

Instantly share code, notes, and snippets.

View arialdomartini's full-sized avatar

Arialdo Martini arialdomartini

View GitHub Profile
@arialdomartini
arialdomartini / karabiner.json
Created May 3, 2020 07:05
Gian "Touch Typing" Pace
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
%export just
||----------------------------------------------------------------------||
|| in this program we move between three different representations of ||
|| text - as a flat list of characters, including spaces and newlines ||
|| - as a list of lines (containing spaces but not newlines) ||
|| - and as a list of list of words. ||
||----------------------------------------------------------------------||
text == [char]
@arialdomartini
arialdomartini / implicitly-captured-closure.cs
Created March 2, 2020 13:25
Implicitly Captured Closure: a
internal static class Foobar
{
private static Bar Foo(Func<Bar, Bar> f) => f(null);
internal class Bar
{
public Bar Use(Bar bar) => throw new NotImplementedException();
}
internal static void Warning()
internal class MyModule : Module
{
readonly SourceSettings[] _settings =
{
new SourceSettings {FTPServerAddress = "ftp1.server1.lab", Filter = "ALL"},
new SourceSettings {FTPServerAddress = "ftp2.server2.lab", Filter = "pdf;docx"},
new SourceSettings {FTPServerAddress = "ftp3.server3.lab", Filter = "pdf"}
};
protected override void Load(ContainerBuilder builder)
@arialdomartini
arialdomartini / PermutationsItertive2.cs
Last active May 20, 2019 09:56
Permutations of a string, with separate pending and permutations
private static IEnumerable<string> PermutationsIterative(string s)
{
var pending = new List<(string permutation, string rest)>
{
("", s)
};
var permutations = new List<string>();
while (pending.Any())
{
@arialdomartini
arialdomartini / PermutationsItertive.cs
Created May 20, 2019 09:41
Permutations of a string, with iterative algorithm
private static IEnumerable<string> PermutationsIterative(string s)
{
var permutations = new List<(string permutation, string rest)>
{
("", s)
};
while (true)
{
if (permutations.All(p => p.rest == ""))
@arialdomartini
arialdomartini / Permutations.cs
Created May 20, 2019 08:49
Calculate permutations recursively
private static IEnumerable<string> Permutations(string s)
=> Permutations("", s).Select(e => e.Item1);
private static IEnumerable<(string, string)> Permutations(string acc, string rest)
{
if (string.IsNullOrEmpty(rest))
return new[] {(acc, rest)};
return rest.SelectMany(c =>
Permutations(
package com.joantolos.kata.social.networking.time;
import com.joantolos.kata.social.networking.domain.TimeLapse;
import com.joantolos.kata.social.networking.ui.Magnitude;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@arialdomartini
arialdomartini / primitive.cs
Last active December 2, 2018 09:40
Primitive Obsession in C#
using FluentAssertions;
using Xunit;
namespace CroMagnon
{
public class PrimitiveTest
{
public class Foo
{
public ConnectionString ConnectionString { get; set; }
@arialdomartini
arialdomartini / goodQuality.cs
Created October 12, 2018 06:55
goodQuality.cs
Result Work(bool goodQuality) =>
goodQuality ? throw new Exception("Should not happen") : GoQuickAndDirty();
Result GoQuickAndDirty() =>
Work(goodQuality: false);