Skip to content

Instantly share code, notes, and snippets.

Avatar

Harm Aarts haarts

View GitHub Profile
@haarts
haarts / gist:baf6ab7d391f0b6a36bf566984e24c6e
Last active Sep 1, 2021
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.
View gist:baf6ab7d391f0b6a36bf566984e24c6e
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 Jun 28, 2021
Dockerfile for running Lucky
View Dockerfile
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 Sep 1, 2020
safe money
View main.dart
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 Oct 28, 2019
A transformer to only allow unique entries. `Unique(memory: 1)` is equivalent to `distinct()`.
View unique.dart
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 = {};
View keybase.md

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 Jul 11, 2019
Elegant retries
View retry.dart
var fail = true;
int sheep() {
if (fail) {
fail = false;
throw Exception("boom!");
}
return 1;
}
@haarts
haarts / version_check.rb
Created Jun 14, 2019
Check if the versions defined in a Dart pubspec file are still up to date
View version_check.rb
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 Jan 3, 2019
log generated with `export LD_DEBUG=symbols`
View symbols.txt
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
View kakrc
colorscheme zenburn
add-highlighter global/ number-lines -relative
add-highlighter global/ show-matching
hook global WinSetOption filetype=python %{
hook window InsertChar \t -group python-indent %{ exec -draft h@ }
}
hook global WinSetOption filetype=git-commit %{
autowrap-enable
View .editorconfig
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# 2 space indentation
[*.dart]
indent_style = space
indent_size = 2