Skip to content

Instantly share code, notes, and snippets.

@graemerocher
graemerocher / App.java
Created May 31, 2021 18:47
Micronaut JBang Example
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.micronaut:micronaut-bom:2.5.4@pom
//DEPS io.micronaut:micronaut-http-server-netty
//DEPS io.micronaut:micronaut-inject-java
//DEPS org.slf4j:slf4j-simple
package app;
import io.micronaut.http.annotation.*;
import io.micronaut.runtime.Micronaut;
@tivrfoa
tivrfoa / Benq-kotlin-script.kt
Created March 20, 2021 19:24
By Benq, contest: Kotlin Heroes: Episode 6, problem: (A) From Zero To Y
/**
* Description: Kotlin tips for dummies
* Source:
* https://codeforces.com/blog/entry/71089
* Kotlin Reference
* https://kotlinlang.org/docs/tutorials/competitive-programming.html
*/
/// episode 1: https://codeforces.com/contest/1170
/// episode 2: https://codeforces.com/contest/1211
/*
* Copyright Gunnar Morling.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package dev.morling;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
@tivrfoa
tivrfoa / jmp.S
Created December 25, 2020 21:16
Infinite Loop in GAS Assembly
# as -o jmp.o jmp.S && ld -s -o jmp jmp.o && ./jmp
#
.text # section declaration
# we must export the entry point to the ELF linker or
.global _start # loader. They conventionally recognize _start as their
# entry point. Use ld -e foo to override the default.
@petrbouda
petrbouda / memory-limit-request-jvm.md
Last active April 30, 2025 18:04
Memory LIMIT and REQUEST in Containers and JVM

Memory LIMIT and REQUEST in Containers and JVM

  • Do you run a JVM inside a container on Kubernetes (or maybe OpenShift)?
  • Do you struggle with REQUEST and LIMIT parameters?
  • Do you know the impact of those parameters on your JVM?
  • Have you met OOM Killer?

Hope you will find answers to these questions in this example-based article.

How to set up JVM Heap size in a Container

///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.quarkus:quarkus-picocli:1.8.1.Final
//Q:CONFIG quarkus.banner.enabled=false
//Q:CONFIG quarkus.log.level=WARN
//DEPS org.twitter4j:twitter4j-core:4.0.7
//JAVA 11+
import picocli.CommandLine;
import javax.enterprise.context.Dependent;
@tivrfoa
tivrfoa / F.java
Created November 22, 2020 23:01
Java Fast Scanner used by tourist
import java.util.*;
import java.io.*;
/*
http://codeforces.com/contest/852/submission/30029310
*/
public class F {
int mod;
@tivrfoa
tivrfoa / git-fetch-pull-request.sh
Created November 20, 2020 12:21
Git Fetch Pull Request
~/dev/git/jbang (master)
$ git fetch origin pull/527/head:fixjfxname
From https://github.com/jbangdev/jbang
* [new ref] refs/pull/527/head -> fixjfxname
~/dev/git/jbang (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.
@tivrfoa
tivrfoa / git-diff.sh
Created November 17, 2020 20:59
Executing git diff from a directory different from the repo
git --git-dir=path/to/repo/.git diff
@RaasAhsan
RaasAhsan / Main.java
Last active June 16, 2023 06:37
minimized ARM memory barrier violation
import java.util.concurrent.atomic.*;
import java.util.concurrent.*;
public class Main {
private static ExecutorService executor = Executors.newFixedThreadPool(2);
private static int iterations = 10000000;
public static class Runner {
// writes to canceled happen before a CAS on suspended
// reads on canceled happen after a CAS on suspended