Skip to content

Instantly share code, notes, and snippets.

View haarts's full-sized avatar

Harm Aarts haarts

View GitHub Profile
@haarts
haarts / gist:b7649e7175d0a579d132f8a6ca2c8cce
Created December 19, 2023 09:11
Offlinemutation GraphQL query 21 Travel
mutation Carrier {
offline {
registerTx(
txDetails: {
asset: DTI4H95J0R2X,
amount: "10",
txId: "123",
originator: {
name: {legal:{lei: "FLGW00QWEOISPQMLHI70", name:"some name"}},
address: {postalCode:"1234", town:"zug", country:"CH"},
@haarts
haarts / dumb_stuff.md
Last active April 21, 2023 16:47
Things I really dislike
  • all no/low code tools
  • java
  • php
  • javascript
  • css
  • everything from Oracle
  • everything from IBM
  • everything from Salesforce
  • X11
  • docker
@haarts
haarts / gist:baf6ab7d391f0b6a36bf566984e24c6e
Last active September 1, 2021 18:11
Final version of the producer. It can (and does) crash but it's under management of Systemd which restarts it after 5 minutes. The only fanciness is the variable sleep time.
require "dotenv"
require "redis"
require "db"
require "pg"
require "log"
module Producer
VERSION = "0.1.0"
Dotenv.load? "env"
Log.setup_from_env(default_level: :debug)
@haarts
haarts / Dockerfile
Created June 28, 2021 19:09
Dockerfile for running Lucky
FROM docker.io/crystallang/crystal:1.0.0
RUN apt update && apt install -y curl gpg postgresql-client tmux
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
RUN curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarnkey.gpg >/dev/null
RUN echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt update && \
@haarts
haarts / main.dart
Last active September 1, 2020 10:04
safe money
abstract class Currency {
const Currency(this.precision, this.currencyCode);
final int precision;
final String currencyCode;
static List<Currency> all() {
return [Chf(), Xbt()];
}
}
@haarts
haarts / unique.dart
Last active October 28, 2019 13:51
A transformer to only allow unique entries. `Unique(memory: 1)` is equivalent to `distinct()`.
class Unique<T> extends StreamTransformerBase<T, T> {
final int memory;
const Unique({this.memory = 10});
Stream<T> bind(Stream<T> stream) => Stream<T>.eventTransformed(
stream, (EventSink sink) => UniqueSink<T>(sink, memory: memory));
}
class UniqueSink<T> implements EventSink<T> {
final EventSink<T> _output;
final Set<T> _seen = {};

Keybase proof

I hereby claim:

  • I am haarts on github.
  • I am haarts (https://keybase.io/haarts) on keybase.
  • I have a public key ASA55JuywI25AAxHvndx2p0bNN_HRUkgK3aVUOKFp9D7wQo

To claim this, I am signing this object:

@haarts
haarts / retry.dart
Created July 11, 2019 09:55
Elegant retries
var fail = true;
int sheep() {
if (fail) {
fail = false;
throw Exception("boom!");
}
return 1;
}
@haarts
haarts / version_check.rb
Created June 14, 2019 13:41
Check if the versions defined in a Dart pubspec file are still up to date
require 'yaml'
require 'net/http'
require 'json'
url = 'https://pub.dev/api/packages/'
local_spec = YAML.load_file('pubspec.yaml')
local_spec["dependencies"].each do |lib, version|
if !version.is_a? String
next
end
@haarts
haarts / symbols.txt
Created January 3, 2019 20:40
log generated with `export LD_DEBUG=symbols`
2415: symbol=_ZNSbIwSt11char_traitsIwESaIwEE4_Rep11_S_max_sizeE; lookup in file=libffmpeg.so [0]
2415: symbol=_ZNSbIwSt11char_traitsIwESaIwEE4_Rep11_S_max_sizeE; lookup in file=/usr/lib/x86_64-linux-gnu/libasound.so.2 [0]
2415: symbol=_ZNSbIwSt11char_traitsIwESaIwEE4_Rep11_S_max_sizeE; lookup in file=/usr/lib/x86_64-linux-gnu/libcups.so.2 [0]
2415: symbol=_ZNSbIwSt11char_traitsIwESaIwEE4_Rep11_S_max_sizeE; lookup in file=/lib/x86_64-linux-gnu/librt.so.1 [0]
2415: symbol=_ZNSbIwSt11char_traitsIwESaIwEE4_Rep11_S_max_sizeE; lookup in file=/lib/x86_64-linux-gnu/libdl.so.2 [0]
2415: symbol=_ZNSbIwSt11char_traitsIwESaIwEE4_Rep11_S_max_sizeE; lookup in file=/lib/x86_64-linux-gnu/libexpat.so.1 [0]
2415: symbol=_ZNSbIwSt11char_traitsIwESaIwEE4_Rep11_S_max_sizeE; lookup in file=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 [0]
2415: symbol=_ZN12v8_inspector8protocol8Debugger3API6Paused10ReasonEnum3XHRE; lookup in file=libnode.so [0]
2415: symbol=_ZN12v8_inspector