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?
If you have a dedicated server with OVHcloud, you can purchase additional IPs, also known as "Fallback IPs", for your server. Because I have enough resources on my dedicated servers, I wanted to give/rent VPSes for my friends for them to use for their own projects, but I wanted to give them the real VPS experience, with a real external public IP that they can connect and use.
So I figured out how to bind an external IP to your LXD container/LXD VM! Although there are several online tutorials discussing this process, none of them worked for me until I stumbled upon this semi-unrelated OVHcloud guide that helped me go in the right direction.
When your Java app crashes due to OutOfMemoryError
, you probably want to automatically restart your application. After all, what's the point of keeping the application running if a OutOfMemoryError
was thrown, since in that case you probably have a memory leak, so trying to catch the error and continue executing the app is unviable.
To do this, you can add -XX:+ExitOnOutOfMemoryError
to your startup flags, this will cause the JVM to automatically exit when a OutOfMemoryError
is thrown, sweet!
However, you may also want to create a heap dump when a OutOfMemoryError
is thrown, to analyze the heap dump later to figure out what triggered the error. In that case, use -XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError
, this will create a heap dump on OutOfMemoryError
and then exit.
You can change the heap dump folder with -XX:HeapDumpPath
, so, if you want to store your heap dumps in the /tmp/dump
folder, use -XX:HeapDumpPath=/tmp/dump
!
Here's how you would use it when starting your application.
java -Xmx1G -Xms1G -XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/dump -jar ...
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?
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:
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
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!
Exposed's exposed-java-time
(and exposed-kotlin-datetime
) module has an issue: In PostgreSQL it uses TIMESTAMP WITHOUT TIME ZONE
and always saves the timestamp using the system's current time zone (ZoneId.systemDefault()
).
So, if you are running your application in two different time zones, the inserted result of Instant.now()
will be different, even if the code was executed at the same nanosecond!
I got bit by this bug in Loritta, where the legacy application was using the America/Sao_Paulo
time zone while the newer slash commands web server was using UTC
. This caused inconsistencies in the database where transactions inserted by the legacy application were older than transactions inserted by the web server!
While you can workaround the issue by using TimeZone.setDefault(TimeZone.getTimeZone("UTC"))
in your code, this isn't a great solution. Besides, it is recommended that you use TIMESTAMP WITH TIME ZONE
, even if you are using a java.time.Instant
!
Thankfully Exposed is very extendable, allowing you to support features that it doesn't support out of the box! So I submitted my TIMESTAMP WITH TIME ZONE
implementation to my ExposedPowerUtils repository, with other nifty Exposed utilities and extensions.
object ActionLog : LongIdTable() {
// Instead of using timestamp, use "timestampWithTimeZone"
// This returns a "Instant"
val timestamp = timestampWithTimeZone("timestamp")
}
Check out the ExposedPowerUtils repository, include the postgres-java-time
in your project, and have fun! Or if you prefer, just copy the JavaTimestampWithTimeZoneColumnType
file to your project.
Keep in mind that Exposed won't change the column type automatically if the table is already created, you can change it by ALTER TABLE sonhostransactionslog ALTER COLUMN timestamp TYPE TIMESTAMP WITH TIME ZONE;
. In my experience, if your current TIMESTAMP WITHOUT TIME ZONE
are in UTC, you shouldn't have any issues when migrating to a TIMESTAMP WITH TIME ZONE
!
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?
Você quer transferir o dinheiro da sua conta jurídica, mas o medo de transferir e a receita te prender é maior? É, eu também estive nessa situação.
Você procura postagens sobre, mas os autores insistem em "Você deve se programar para transferir mensalmente uma quantidade exata de dinheiro! Nem mais, nem menos!"... Mas isso não resolve a sua dúvida! Você só quer saber quantas vezes e quando você pode transferir da sua conta jurídica para a pessoa física sem que você acabe na prisão, sem essas baboseiras de "boas práticas" que tanto pregam!
Você pensa no tal "pró-labore", o salário que você definiu como sócio... "m-mas, me indicaram colocar o valor do salário mínimo para não pagar tanto dinheiro para o INSS! Eu não consigo viver com o salário que eu defini no pró-labore!", e você começa a imaginar como vai ser a sua vida recebendo apenas um salário mínimo...
"Chega!", você pensa, "Eu não ligo para as boas práticas! Eu só quero saber se eu posso transferir o meu dinheiro para a conta pessoal sem eu ir para o xilindró!!". E aqui está a solução do seu sofrimento, pois eu também passei pela mesma situação na minha empresa de pequeno porte.
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?
Se você deseja vender produtos virtuais, você se depara com uma dúvida: Devo emitir uma nota fiscal eletrônica (NF-e) ou uma nota fiscal de serviços eletrônica (NFS-e)?
Você pensa "Bem, se eu estou vendendo um produto virtual, eu devo emitir uma nota fiscal eletrônica, pois eu não estou dando um serviço!", mas acaba batendo de cara com dois requisitos importantíssimos para emitir uma nota fiscal eletrônica, requisitos que fazem o menor sentido se você está vendendo um produto virtual.
Na minha empresa eu tenho a Loritta e o SparklyPower, e neles eu vendo produtos virtuais, então eu tive essa dúvida... Qual delas devem ser emitidas? Muitas postagens na internet falam sobre notas fiscais para "e-commerce", ou seja, vendas de produtos físicos pela internet, em vez de falarem sobre produtos virtuais.
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?
/u/etherSand perguntou no /r/ConselhosLegais se uma empresa paga imposto mesmo se ela não emitir uma nota fiscal. No caso, ela não pode criar um MEI e teria que criar uma empresa.
Eu não sou contador! Eu sou desenvolvedor e prefiro passar o meu tempo desenvolvendo tranqueiras do que tentar compreender todas as diversas maneiras do governo se apoderar do seu dinheiro, mas como eu tenho uma empresa eu resolvi compartilhar a minha experiência baseando na minha empresa, que atualmente é uma empresa de pequeno porte.
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?
"Será que eu deveria trancar o curso?" é um pensamento recorrente na vida de qualquer aluno que cursa faculdade, como também é uma das decisões mais difíceis que um aluno deve tomar.
Alguns caem fora e saem da faculdade, o que não é uma má ideia considerando o tempo que ela perderá como também o estresse e a depressão que ela adquiria ao longo do curso. Enquanto outros decidem apostar na sorte e deixam o destino levá-las.
Eu fui uma das pessoas que deixou o destino me levar, guiado pelo medo e as represálias de trancar o curso...
Mas ontem, 21/02/2022, depois de cinco anos após eu ter entrado na faculdade, eu formei-me na PUC-SP em Ciência da Computação!
Neste post eu estou deixando algumas dicas para os que estão no mesmo buraco que eu estive e precisam de uma luz para guiá-los, pois enfrentar algo percorrendo o caminho que outros já passaram é muito mais fácil do que ir pela escuridão.
Não são as dicas genéricas que você já conhece, e sim dicas de qualidade duvidosa e de eficácia não comprovada, mas se você já está no fundo do poço, qualquer luz é melhor que a escuridão, não é mesmo?
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?
Alguns dias atrás eu contratei um plano de internet fibra e internet móvel na Vivo como empresa jurídica, tudo correu bem até eu ter tentado acessar a minha conta pelo Meu Vivo Empresas e perceber que...
Fiquei desesperado pensando "meu deus e se eu for preso por não pagar as contas???", então tive que descobrir como eu poderia alterar os dados da empresa do Meu Vivo Empresas, e após vários momentos de ansiedade, ligações para a Vivo e conversas pelo atendimento via chat, eu descobri como você pode arrumar os seus dados na Vivo Empresas!
perfectionisperfect asked on /r/admincraft how MineAlong put an image in Minecraft's TAB list.
In the thread there were a lot of people saying "oh it is just a resource pack" but no one was saying how they did it, which is what OP asked for. So here's how they did it!