Skip to content

Instantly share code, notes, and snippets.

Avatar

Mitsunori Komatsu komamitsu

View GitHub Profile
@komamitsu
komamitsu / systemd-xremap.md
Created January 14, 2023 14:07
Execute xremap from systemd
View systemd-xremap.md

Create /etc/systemd/system/xremap.service file

[Unit]
Description=xremap service
After=default.target

[Service]
ExecStart=/usr/bin/xremap /home/komamitsu/xremap.yml
View UnixDomainSocketTest.java
package org.komamitsu.unixdomainsockettest;
import java.net.StandardProtocolFamily;
import java.net.UnixDomainSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
View RewriteSampleWithCalcite.kotlin
fun calcite() {
val schema = Frameworks.createRootSchema(true)
val config = Frameworks.newConfigBuilder()
.defaultSchema(schema)
.sqlValidatorConfig(SqlValidator.Config.DEFAULT)
.parserConfig(
SqlParser.config()
.withQuoting(Quoting.BRACKET)
.withCaseSensitive(true)
@komamitsu
komamitsu / log.md
Created March 7, 2022 05:04
AMD sleep issue with Ubuntu 20.04
View log.md
Mar 07 13:53:46 komamitsu-laptop systemd[1]: Reached target Sleep.
Mar 07 13:53:46 komamitsu-laptop systemd[1]: Starting Record successful boot for GRUB...
Mar 07 13:53:46 komamitsu-laptop systemd[1]: Starting NVIDIA system suspend actions...
Mar 07 13:53:46 komamitsu-laptop suspend[2802]: nvidia-suspend.service
Mar 07 13:53:46 komamitsu-laptop logger[2802]: <13>Mar  7 13:53:46 suspend: nvidia-suspend.service
Mar 07 13:53:46 komamitsu-laptop systemd[1]: grub-common.service: Succeeded.
Mar 07 13:53:46 komamitsu-laptop systemd[1]: Finished Record successful boot for GRUB.
Mar 07 13:53:46 komamitsu-laptop systemd[1]: nvidia-suspend.service: Succeeded.
Mar 07 13:53:46 komamitsu-laptop systemd[1]: Finished NVIDIA system suspend actions.
@komamitsu
komamitsu / key-remap-on-xkb.md
Last active January 14, 2023 14:08
Key remapping on Linux using xkb-options
View key-remap-on-xkb.md

Goal

  • Make Muhenkan key a left Control key
  • Make Hiragana Katakana key an Escape key
  • Make Capslock key a Zenkaku Hankaku key

Options

  • xmodmap: Easy, but my laptop's suspend/resume resets xmodmap configuration
  • xkb: Let's try this
View JPKeyboard.ahk
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; ^M
^M::Enter
; ^H
^H::BackSpace
View JsonParser.java
import java.util.*;
class JsonParser {
private Object parsePrimitive(StringTokenizer tokenizer, String token) {
if (token.startsWith("\"")) {
if (token.endsWith("\"")) {
return token.subSequence(1, token.length() - 1);
}
StringBuilder builder = new StringBuilder(token);
@komamitsu
komamitsu / SharedStringMethod.java
Last active November 29, 2021 03:15
GraalVM shared library example which receives String arguments called from C
View SharedStringMethod.java
package org.komamitsu.foobar;
import org.graalvm.nativeimage.IsolateThread;
import org.graalvm.nativeimage.c.function.CEntryPoint;
import org.graalvm.nativeimage.c.type.CCharPointer;
import org.graalvm.nativeimage.c.type.CTypeConversion;
public class SharedStringMethod
{
@CEntryPoint(name = "add")
View Commands.txt
function wrap_jth {
grep 'daemon prio=' $1 | ruby -rcsv -ne 'puts CSV.parse($_,{:col_sep => "\s"}).first.first.gsub(/\d/, "0")' | sort | uniq -c
}
@komamitsu
komamitsu / ArithmeticCodeEvaluator.java
Created June 9, 2019 14:38
Small S-exp like arithmetic code interpreter in Java
View ArithmeticCodeEvaluator.java
package org.komamitsu.test;
import java.util.StringTokenizer;
public class ArithmeticCodeEvaluator
{
private static int eval(StringTokenizer tokenizer)
{
String first = tokenizer.nextToken();
if (first.equals("+")) {