Skip to content

Instantly share code, notes, and snippets.

View piksel's full-sized avatar
📠

nils måsén piksel

📠
View GitHub Profile
type ObjectKeys<T> = { [P in keyof T]: T[P] extends object ? P : never }[keyof T];
type FirebaseInit<T> = Omit<T, ObjectKeys<T>> & {[P in ObjectKeys<T>]: ''}
@piksel
piksel / docker compose
Created July 8, 2021 16:45
Change in containers created by docker compose
# Using docker subcommand `compose`
$ docker compose up
$ docker container inspect kafka -f ' Image: {{ .Image }}{{"\n"}}Config.Image: {{.Config.Image}}'
Image: sha256:d694642b6bef4693082bd6192d923f37af9e27ef15beef9de7d93a51d1a5d74d
Config.Image: sha256:d694642b6bef4693082bd6192d923f37af9e27ef15beef9de7d93a51d1a5d74d
@piksel
piksel / MainWindow.xaml
Last active June 23, 2021 10:34
Avalonia style selector bug (?)
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:AvaloniaTest.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AvaloniaTest.Views.MainWindow"
Icon="/Assets/avalonia-logo.ico"
Title="AvaloniaTest">
<Window.Styles>
@piksel
piksel / have_key_value_matcher.go
Created May 21, 2021 12:59
HaveKeyValue gomega matcher
package metrics
import (
"fmt"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/matchers"
"github.com/onsi/gomega/types"
"reflect"
"strings"
)
using (var outStream = new MemoryStream())
{
var zipOutputStream = new ZipOutputStream(outStream);
await outStream.FlushAsync(cancellationToken);
outStream.Seek(0, SeekOrigin.Begin);
zipOutputStream.SetLevel(CompressionMax);
foreach (var file in files)
{
using (var inStream = new MemoryStream())
{
using System.Linq;
using static System.IO.File;
using static System.Console;
int GetTreeProd(string[] map, params (int x, int y)[] strats)
=> strats.Aggregate(1, (a, t) => a * Enumerable.Range(0, map.Length / t.y).Count(i => map[t.y * i][t.x * i % map[0].Length] == '#'));
var map = ReadAllLines("input.txt");
WriteLine($"Silver: {GetTreeProd(map, (3, 1))}");
WriteLine($"Gold: {GetTreeProd(map, (1,1), (3,1), (5,1), (7,1), (1,2))}");
using System.IO;
using System.Collections.Immutable;
using System.Linq;
using static System.Linq.Enumerable;
using static ConLib.PrettyConsole;
var seats = new bool[0b1111111111];
foreach (var line in File.ReadLines("input.txt"))
seats[line.Select(s => "BR".Contains(s) ? 1 : 0).Aggregate(0, (a, b) => b | a << 1)] = true;
using System.Linq;
using static System.IO.File;
using static System.Console;
using System.Text.RegularExpressions;
var required = new [] {"byr","iyr","eyr","hgt","hcl","ecl","pid"};
var eyecol = new [] {"amb", "blu", "brn", "gry", "grn", "hzl", "oth"};
bool numInRange(string y, int min, int max) => int.TryParse(y, out int yr) && yr >= min && yr <= max;
bool heightValid(string h)
@piksel
piksel / monokai-pkmod.xml
Last active December 3, 2020 12:38
Modified monokai theme for Notepad++
<?xml version="1.0" encoding="Windows-1252" ?>
<!--//
Monokai-pkmod
Copyright (c) 2008 Fabio Zendhi Nagao <http://zend.lojcomm.com.br/>
Modifications by nils, piksel bitworks
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
@piksel
piksel / go.mod.diff
Last active November 22, 2020 07:47
Suggested go.mod for watchtower PR #674
git diff origin/master -- go.mod
index 300eb31..d549e82 100644
--- a/go.mod
+++ b/go.mod
@@ -39,8 +39,8 @@ require (
github.com/lib/pq v1.2.0 // indirect
github.com/miekg/pkcs11 v0.0.0-20190401114359-553cfdd26aaa // indirect
github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c // indirect
- github.com/onsi/ginkgo v1.8.0
- github.com/onsi/gomega v1.5.0