Skip to content

Instantly share code, notes, and snippets.


Renato Athaydes renatoathaydes

View GitHub Profile
renatoathaydes / main.dart
Created August 23, 2022 11:11
Dart - processing stream of JSON documents
View main.dart
import 'dart:convert';
main() async {
const jsons = '{"foo": "Ø"}\n{"bar": false}';
final bytes = utf8.encode(jsons);
// partitions breaking the bytes between invalid UTF-8 boundaries
final partitions =
Stream.fromIterable([bytes.sublist(0, 10), bytes.sublist(10)]);
renatoathaydes /
Created January 20, 2022 10:36
Typescript api-extractor bug

This project demonstrates a problem with api-extractor.

My objective is the following:

  • I have a Typescript file which defines a basic API.
  • I want this file to be used for generating a declarations TS file (.d.ts file).
  • I don't want to generate actual JS files as those are not relevant.
  • Use the .d.ts file to generate markdown docs for my API.

The source file is in the ts-project directory, so I tell tsc:

renatoathaydes /
Created December 21, 2021 17:11
Demonstration of how Java async methods are misleading, at best.
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
class Scratch {
public static void main(String[] args) throws Exception {
var singleThreadedExecutor = Executors.newSingleThreadExecutor();
var startTime = System.currentTimeMillis();
renatoathaydes / gist:1d59b1a93d83e97774bbc4fd8cd62929
Created December 16, 2021 07:23
Log4j2-core jar jdeps output
View gist:1d59b1a93d83e97774bbc4fd8cd62929
▶ jdeps --multi-release 11 out/log4j-core-2.16.0.jar
log4j-core-2.16.0.jar -> java.base
log4j-core-2.16.0.jar -> java.compiler
log4j-core-2.16.0.jar -> java.desktop
log4j-core-2.16.0.jar -> java.logging
log4j-core-2.16.0.jar ->
log4j-core-2.16.0.jar -> java.naming
log4j-core-2.16.0.jar -> java.rmi
log4j-core-2.16.0.jar -> java.scripting
log4j-core-2.16.0.jar -> java.sql
renatoathaydes / main.dart
Created December 4, 2021 10:25
Skyline problem implementation in Flutter. Based on
View main.dart
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
import 'dart:math' as math;
void main() => runApp(MyApp());
class Rectangle {
renatoathaydes /
Last active October 24, 2021 08:36
Using static variables in local scope in Java.
import java.util.regex.Pattern;
public class Test {
public static void main(String[] args) {
static Pattern compile(String pattern) {
System.out.println("compile(" + pattern + ")");
renatoathaydes / dart-null-safe-final-field-fail.dart
Created November 6, 2020 19:39
This fails to compile on line 18, but it should work because the field is final so the null check ensures the field can't be null
View dart-null-safe-final-field-fail.dart
// Welcome to the null safety version of DartPad!
// This site has a dev channel release of the
// Dart SDK with null safety enabled. You can
// play around with code of your own, or pick a
// learning exercise from the snippets menu at
// the top-right of this page.
void main() {
renatoathaydes /
Last active May 17, 2020 16:50
Taking Project Loom for a spin
package loom;
import rawhttp.core.RawHttp;
import rawhttp.core.RawHttpRequest;
import rawhttp.core.RawHttpResponse;
import rawhttp.core.client.TcpRawHttpClient;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.CountDownLatch;
renatoathaydes /
Last active May 4, 2020 18:19
Calculating a number from its constituent parts (encoded as ASCII bytes)
import java.nio.charset.StandardCharsets;
class JavaComparison
public static void main(String[] args)
for (int i = 0; i < 100; i++)
renatoathaydes / Dockerfile
Created July 6, 2019 11:28
Minimalistic Docker image from a simple Dart application - includes only the AOT-compiled app and dartaotruntime.
View Dockerfile
FROM google/dart AS dartc
ADD pubspec.* /app/
RUN pub get
ADD bin/ /app/bin/
ADD lib/ /app/lib/
RUN pub get --offline
RUN dart2aot /app/bin/main.dart /app/main.aot