Skip to content

Instantly share code, notes, and snippets.

View games647's full-sized avatar

games647 games647

View GitHub Profile
@games647
games647 / Origin-focus steal.kwinrule
Last active May 20, 2022 13:54
KDE window rule to prevent Origin launcher in steam proton/wine to steal the focus if notifications pop up like achievements, chat message or opening the overlay itself. To import it select window rules in KDE, click import and then import the file below.
[Origin no minimize (low enough for notification but still allows dialogs (e.g. close dialog))]
Description=Origin no minimize (low enough for notification but still allows dialogs (e.g. close dialog))
fsplevel=1
fsplevelrule=2
skipswitcher=true
skipswitcherrule=2
title=Origin
titlematch=1
types=1
wmclass=steam_(proton|app_[0-9])
@games647
games647 / ReflectionTest.java
Created May 18, 2020 14:43
Java Reflection performance
package org.sample;
import java.lang.invoke.LambdaMetafactory;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.invoke.MethodType;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.UUID;
"""
Copyright 2011 Tyler Kennedy <tk@tkte.ch>. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list
@games647
games647 / gist:de40f74e06a7fd67ff2208257a0ebc02
Created March 3, 2020 10:06
Advanced Networking processing
https://programming.vip/docs/java-non-blocking-io-and-asynchronous-io.html
Differentiation into
Blocking mode IO (Single thread)
-> Often standard
Asychrnous blocking IO
-> many thready only waiting
-> spawn a new thread for every blocking call
Non-blocking IO
-> single-thread can select over multiple connection and get notified on changes
* https://en.wikipedia.org/wiki/Zero-copy
* Java input streams can support zero-copy through the java.nio.channels.FileChannel's transferTo() method if the underlying operating system also supports zero copy
* Only **from** file
* Linux: sendFile call
* Windows: TransmitFile
* Linux 4.18 supports **from** socket zero-copy
* Microsoft Windows supports zero-copy through the TransmitFile API.
* Alternative: Mapping direct memory telling the kernel to use that
Limit 1 only necessary if not over unique keys
HikariCP:
// default prepStmtCacheSize 25);
// default prepStmtCacheSqlLimit 256 - length of SQL
// disabled by default - will return the same prepared statement instance
config.addDataSourceProperty("cachePrepStmts", true);
// default false - available in newer versions caches the statements server-side
config.addDataSourceProperty("useServerPrepStmts", true);
@games647
games647 / gist:924ae035ab3586e6bbee2894b4b64cd5
Last active March 7, 2020 20:56
Java HTTP Keep-Alive Summary
* HTTP Keep alives are enabled by default and hold a connection up to a couple of minutes.
* By default up to 5 connections per destination are hold up
* You can disable it by calling explicitly disconnect
(Note: For android you should call disconnect always)
* For re-use the following has to be true
* share similar settings like same **instance** of SSLFactory
* Server has to accept keep-alive (no close)
* Fully consume inputstream, outputstream and errorstream and close it
(Since JDK 6: spawns a extra thread that consume some remaining data if the length is longer it's not used for keep-alives)
@games647
games647 / grep-http.sh
Created February 11, 2020 10:06
Grep HTTP (not HTTPS) links without maven.apache.org or www.w3.org
grep -r -P "(?:http://(?!(maven\.apache\.org)|www\.w3\.org))+"

Keybase proof

I hereby claim:

  • I am games647 on github.
  • I am games647 (https://keybase.io/games647) on keybase.
  • I have a public key whose fingerprint is 7609 DC1C 8527 453A 59B3 1627 E9E9 62F0 8F62 1538

To claim this, I am signing this object:

@games647
games647 / Intel_Meltdown_Spectre_Inside_Sticker.svg
Created February 3, 2018 11:35
Inspired by https://github.com/anuejn/meltdown-spectre-stickers. This is SVG for the meltdown, spectre inside stickers. So that you can customize and scale it on your own. Sources: Background - http://logos.wikia.com/wiki/File:Intel_Xeon_Phi_logo.svg ; Meltdown, Spectre - https://meltdownattack.com or https://spectreattack.com/meltdown.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.