Java's ScheduledExecutorService has a nifty scheduleAtFixedRate API, which allows you to schedule a Runnable to be executed in a recurring manner.

Mimicking scheduleAtFixedRate seems easy, after all, isn't it just a while (true) loop that invokes your task every once in a while?

GlobalScope.launch {
    while (true) {
        println("Hello World!! Loritta is so cute :3")
        delay(5_000)
    }
}

And it seems to work fine, it does print Hello World!! Loritta is so cute :3 every 5s! And you may be wondering: What's wrong with it?


Recently, I've noticed that my Minecraft server's MOTD was suspiciously switching to my subservers' MOTD if I connected to my subserver and then quit. This was more noticeable if there was a network issue that caused the client to disconnect, due to Minecraft not automatically refreshing the server list.

But how? This is impossible! The Status Response Packet can only be sent if the user is in Status state, not in Play state!

Or perhaps, it ain't impossible since Server Data Packet's introduction in Minecraft 1.19.

Why it exists? While I'm not sure, I think it is related to Minecraft's new reporting system, because it is used to show the infamous "Chat messages can't be verified" toast.

Since BungeeCord dd3f820, the packet is now parsed and blocked on BungeeCord's side, so this is already fixed in newer BungeeCord/Waterfall versions, yay!


This content is not available in your language... So if you don't understand the language... well, at least you can appreciate the pictures of the post, right?

Desde pequeno eu sempre sonhei em ser um YouTuber famoso, mas nunca tive uma verdadeira oportunidade de cair de cabeça nisso, pois nunca tive um quarto que possuisse paz e harmonia para eu poder criar vídeos sem eu ser interrompido.

Eu queria ser um streamer programador de sucesso igual ao... hm... Eu não conheço ninguém que programa, que faz streaming e que faz sucesso... Tanto faz! Eu vou ser o primeiro a conquistar essa marca, pois eu sou especial!

Um tal de Ben Awad já falou de todos os problemas sobre fazer live streaming de programação, mas eu vou conseguir superar os problemas, pois novamente, eu sou especial! Aluguei até um escritório para que eu possa ter a paz e harmonia que eu tanto almejava, para que a stream fosse perfeita e eu conseguisse ser popular no mesmo nível de famosos como o SypherPK, Ludwig, Ninja, Pokimane... Ah, mal posso esperar por isso!

O salafrário do Ben Awad tentando estragar os meus sonhos aff

...

Até que eu experimentei fazer streams de programação, e a realidade é mais enfadonha que a ilusão que eu tinha.


A origem do nickname MrPowerGamerBR

Publicado às 23/08/2022 10:00

This content is not available in your language... So if you don't understand the language... well, at least you can appreciate the pictures of the post, right?

Desde 2011 eu usava o nickname "SonicteamPower" para as coisas aleatórias que eu fazia na internet, dentre elas, o meu blog e o meu canal no YouTube, onde eu tentava realizar o meu sonho de ser um YouTuber famoso que passa o dia jogando games.

  • Sonic Team = equipe da SEGA que faz jogos do Sonic
  • Power = parte roubada do nome do antigo fansite Power Sonic

Mas em 2013 eu decidi mudar o meu nick para algo melhor... algo mais cativante, pois o meu sonho de tentar ser um YouTuber de sucesso tinha acabado após ter sido rejeitado da TGN, uma network de YouTubers que eu queria entrar nela pois o cazum8 estava nela e eu era muito fã dele. Então, ao invés de resolver o verdadeiro problema de não me aceitarem (meus vídeos não eram bons), eu decidi mudar de nickname para dar um ar novo a minha carreira de YouTuber.

power do passado was built different

Eu queria colocar "PowerGamer", mas na época o YouTube não deixava dois canais terem o mesmo nome, então o YouTube me sugeriu colocar "MrPowerGamer", e aí eu taquei um "BR" no final só para saberem que eu sou brasileiro. Enquanto para nós o "BR" deixa claro que eu sou brasileiro, já conheci muito gringo que não sabia que o "BR" do meu nick significava "Brasil".

No começo de 2014 eu usava o nickname "LeonardoGamer", mas esse nome era tão genérico e sem graça que depois eu voltei a usar "MrPowerGamerBR".

Enquanto hoje em dia o meu nickname tem um ar tosco e antiquado, com pessoas dizendo "troca isso, parece nick de youtuber de 2013", eu gosto dele e não pretendo mudar, pois eu já fiz muitas coisas com esse nick e as pessoas acabam me reconhecendo por causa dele, me deixando feliz pois é como você tivesse deixado uma "marca" na vida da pessoa.

E o melhor de tudo, ele é único!



This content is not available in your language... So if you don't understand the language... well, at least you can appreciate the pictures of the post, right?

No /r/brdev, /u/sock_templar compartilhou um endpoint dos Correios que permite você rastrear pacotes dos Correios.

curl https://proxyapp.correios.com.br/v1/sro-rastro/CodigoDeRastreioAqui

Ela mostra os eventos sobre o pacote, parecido com os eventos que você recebe ao rastrear um pacote pelo website dos Correios, e inclusive esse endpoint é usado em várias libraries que existem pela internet.

Mas sabia que existe outro endpoint de rastreio dos Correios, que mostra mais informações sobre o pacote sendo rastreado, como também permite você rastrear vários pacotes em um único request?


If your PostgreSQL instance is randomly going into recovery mode... Have you checked if your disk is full?

2022-04-26 13:22:24.962 UTC [382] LOG: database system was not properly shut down; automatic recovery in progress

In the past, if my PostgreSQL LXC container disk was full, PostgreSQL would throw I/O errors when trying to write new data to it, so when my instance was randomly going into recovery, I was stumped, what is causing this?

Until by accident I noticed that my disk was dangerously close to full, so I've decided to check if the disk being full could be culprit of why it was going into recovery, and, fortunately, it was!

My theory is that this was a change made in newer PostgreSQL versions. If the disk is full, fsync fails, which causes PostgreSQL to consider that the data is now unreliable and starts restoring the database state from WAL files. Previous PostgreSQL versions were using fsync incorrectly, then changing how it works so, if fsync fails, PostgreSQL will automatically shut down and initiate recovery mode.

Or maybe it is because I migrated my LXC container from a EXT4 partition to ZFS, who knows!

But if your free disk space is suspiciously low after a recover, and you want to be sure that this is what triggered recovery: Create a large file that fits in your free disk space, wait until PostgreSQL tries doing any I/O, and check if PostgreSQL crashes and starts automatic recovery. If yes, then your disk being full is what could have triggered recovery mode!

However, you may be wondering...

If the issue was that there wasn't any free space, how PostgreSQL was able to successfully recover and start up again?

When PostgreSQL finishes its recovery process, a bunch of free space was cleared up, this may be because PostgreSQL was reading data from WAL files, applying them to the tables' data, and then deleting the WAL files, which ends up freeing disk space, and that allows PostgreSQL to continue working until the disk fills up again.

Anyhow, if your PostgreSQL is randomly going into recovery for no apparent reason, don't forget to check your available free disk space!


Trying to figure out how to list files from a Java Resources folder is hard, there are tons of solutions on StackOverflow, however most of them are weird hacks and they only work when executing your app via your IDE, or when executing your app via the command line, not both.

Joop Eggen's answer is awesome, however it can only do one of two things:

  • Read the resources content when running from a IDE
  • Read the resources content when running the JAR via the command line

So here's an example (Kotlin, but it should be easy to migrate it to Java) that allows you to have both: Reading the resources content when running from a IDE or via the command line!

    val uri = MainApp::class.java.getResource("/locales/").toURI()
    val dirPath = try {
        Paths.get(uri)
    } catch (e: FileSystemNotFoundException) {
        // If this is thrown, then it means that we are running the JAR directly (example: not from an IDE)
        val env = mutableMapOf<String, String>()
        FileSystems.newFileSystem(uri, env).getPath("/locales/")
    }

    Files.list(dirPath).forEach {
        println(it.fileName)
        if (it.fileName.toString().endsWith("txt")) {
            println("Result:")
            println(Files.readString(it))
        }
    }

StackOverflow Post: https://stackoverflow.com/a/67839914/7271796


Carteiras Recomendadas da Itaú Corretora

Publicado às 19/08/2022 10:20 • #stocks

This content is not available in your language... So if you don't understand the language... well, at least you can appreciate the pictures of the post, right?

A Itaú Corretora, como a maioria das corretoras que existem por aí, possui carteiras recomendadas que podem ser acessadas pelo Home Broker deles, assim dando um incentivo para a pessoa a continuar a usar o sistema de corretagem deles e continuar a fazer a pessoa sonhar que, algum dia, ela irá se tornar rica com ações.

Enquanto algumas carteiras, como a Top Five, Small Caps e Dividendos estão apenas disponíveis ao estar conectado na sua conta na corretora, outras estão disponíveis para qualquer um ver e apreciar as ações recomendadas.

É possível encontrar o link dessas carteiras vasculhando pelo Google, mas para facilitar, aqui estão elas!

CarteiraURL
Carteira de BDRshttps://itaucorretora.com.br/carteira-de-bdrs.aspx
Carteira de BDRs Elevenhttps://itaucorretora.com.br/assessoria/carteira-de-bdrs-eleven.aspx
Carteira do Grafistahttps://itaucorretora.com.br/assessoria/carteira-do-grafista.aspx
Carteira Renda com Imóveis - Fundos Imobiliárioshttps://itaucorretora.com.br/carteira-renda-com-imoveis---fundos-imobiliarios.aspx
Carteira de ETFs e Fundos Indexadoshttps://itaucorretora.com.br/carteira-de-etfs-e-fundos-indexados.aspx
Carteira Recomendada - Incentivadas - Debêntures e CRAshttps://itaucorretora.com.br/carteira-recomendada---incentivadas---debentures-e-cras.aspx


I needed to reload my network interface on the machine where my PostgreSQL database is hosted and, after doing that, my thread got forever blocked on the getNotifications(...) call.

"Loritta PostgreSQL Notification Listener" #261 daemon prio=5 os_prio=0 cpu=48.89ms elapsed=62372.91s tid=0x00007f45f806a460 nid=0xf08b5 runnable  [0x00007f45d6dfc000]
   java.lang.Thread.State: RUNNABLE
        at sun.nio.ch.Net.poll([email protected]/Native Method)
        at sun.nio.ch.NioSocketImpl.park([email protected]/NioSocketImpl.java:181)
        at sun.nio.ch.NioSocketImpl.timedRead([email protected]/NioSocketImpl.java:285)
        at sun.nio.ch.NioSocketImpl.implRead([email protected]/NioSocketImpl.java:309)
        at sun.nio.ch.NioSocketImpl.read([email protected]/NioSocketImpl.java:350)
        at sun.nio.ch.NioSocketImpl$1.read([email protected]/NioSocketImpl.java:803)
        at java.net.Socket$SocketInputStream.read([email protected]/Socket.java:966)
        at sun.security.ssl.SSLSocketInputRecord.read([email protected]/SSLSocketInputRecord.java:478)
        at sun.security.ssl.SSLSocketInputRecord.readHeader([email protected]/SSLSocketInputRecord.java:472)
        at sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket([email protected]/SSLSocketInputRecord.java:70)
        at sun.security.ssl.SSLSocketImpl.readApplicationRecord([email protected]/SSLSocketImpl.java:1455)
        at sun.security.ssl.SSLSocketImpl$AppInputStream.read([email protected]/SSLSocketImpl.java:1059)
        at org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:161)
        at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:128)
        at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:113)
        at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:73)
        at org.postgresql.core.PGStream.receiveChar(PGStream.java:453)
        at org.postgresql.core.v3.QueryExecutorImpl.processNotifies(QueryExecutorImpl.java:789)
        - locked <0x0000000621293410> (a org.postgresql.core.v3.QueryExecutorImpl)
        at org.postgresql.jdbc.PgConnection.getNotifications(PgConnection.java:1107)
        at net.perfectdreams.loritta.cinnamon.pudding.utils.PostgreSQLNotificationListener.run(PostgreSQLNotificationListener.kt:29)
        at java.lang.Thread.run([email protected]/Thread.java:833)

So I went out and tried figuring out if this could be reproduced, and found out that someone had already reported this issue, but it was closed due to "lack of feedback". Anyhow, here's my investigations and explanations to anyone else wondering why their PostgreSQL getNotifications call is not receiving new notifications, even tho it is blocked on the getNotifications call!


This content is not available in your language... So if you don't understand the language... well, at least you can appreciate the pictures of the post, right?

Muitas pessoas me perguntam se é possível fazer um bot para o Discord apenas usando um celular... então eu descobri uma maneira de rodar bots feitos em várias linguagens, como JavaScript, Python, Java, entre outros, tudo pelo seu celular!

Perfeito se você quer fazer o seu bot do jeito que bots são feitos pelo computador, como também você não precisa gastar dinheiro para manter o seu bot online... exceto o gasto com energia para deixar o seu celular ligado né rsrs.

Enquanto o vídeo mostra eu rodando um bot feito usando o discord.js pelo Termux, nada impede de você rodar bots feitos em Python, Java, ou em outras linguagens. Basta instalar o pacote necessário da linguagem no Termux, copiar os arquivos da linguagem e rodar!