This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package name.stokito.memeater; | |
import org.apache.derby.iapi.services.memory.LowMemory; | |
import java.lang.Thread.UncaughtExceptionHandler; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class MemoryEater { | |
private static final int MB = 1048576; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**This example illustrates how to extract the sign (the leftmost bit), exponent (the 8 following bits) and mantissa (the 23 rightmost bits) from a float in Java.*/ | |
void floatDestuct() { | |
int bits = Float.floatToIntBits(-0.005f); | |
int sign = bits >>> 31; | |
int exp = (bits >>> 23 & ((1 << 8) - 1)) - ((1 << 7) - 1); | |
int mantissa = bits & ((1 << 23) - 1); | |
System.out.println(sign + " " + exp + " " + mantissa + " " + | |
Float.intBitsToFloat((sign << 31) | (exp + ((1 << 7) - 1)) << 23 | mantissa)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Just for test purposes it would be nice to automatically generate test array (haystack) in which to find a needle. | |
; Fill memory with 8 elements: 0, 1.. 7 and value of element corresponds to it's addresses. | |
mvi b, 7 ; last index to fill untill | |
mvi h, 0 ; set up HL as memory pointer | |
mvi l, 0 ; set up HL as memory pointer | |
loop: inr l ; increase l by one | |
mov m, l | |
mov a, l | |
cmp b | |
jm loop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.cloudflare.com/ips replace the ips-v4 with ips-v6 if needed | |
# https://blog.cloudflare.com/cloudflare-now-supporting-more-ports/ | |
for ip in `wget -qO- http://www.cloudflare.com/ips-v4`; do | |
iptables -I INPUT -p tcp -m multiport --dports 80,443,8080,8443,2052,2053,2082,2083,2086,2087,2095,2096,8880 -s $ip -j ACCEPT | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<include resource="org/springframework/boot/logging/logback/defaults.xml"/> | |
<property scope="context" name="pattern.singleLine.true" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z', UTC} %5p %logger [%t] \(%X{trace}\) %X{loggingMessageExtender}: %replace(%m%n%ex){'\n(?=[^$])','\\n'}%nopex" /> | |
<property scope="context" name="pattern.singleLine.false" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z', UTC} -%5p %logger [%t] \(%X{trace}\) %X{loggingMessageExtender}: %m%n" /> | |
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | |
<encoder> | |
<Pattern>${pattern.singleLine.${SINGLE_LINE_PATTERN:-false}}"</Pattern> | |
</encoder> | |
</appender> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.stokito.experiments; | |
import static java.util.concurrent.TimeUnit.MILLISECONDS; | |
import static org.openjdk.jmh.annotations.Mode.Throughput; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Locale; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.BenchmarkMode; | |
import org.openjdk.jmh.annotations.Level; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# last three commits | |
git format-patch -3 --stdout > multi_commit.patch | |
# all commits that are in your branch and not in master into a single patch file multi_commit.patch | |
git format-patch --signoff master --stdout > multi_commit.patch | |
# create patches in the folder ~/output/directory/ for all commits that are in your branch and not in master | |
git format-patch -o ~/output/directory/ --signoff master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FILE=$(zenity --file-selection); echo $FILE; if [ -w "$FILE" ]; then pluma "$FILE"; else pkexec pluma "$FILE"; fi; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Search pattern: (.*)(//)(.*)(\n) | |
Replace with: $1/\*$3 \*/$4 |