Skip to content

Instantly share code, notes, and snippets.

View komamitsu's full-sized avatar

Mitsunori Komatsu komamitsu

View GitHub Profile
#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
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 May 28, 2024 23:20
GraalVM shared library example which receives String arguments called from C
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")
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
package org.komamitsu.test;
import java.util.StringTokenizer;
public class ArithmeticCodeEvaluator
{
private static int eval(StringTokenizer tokenizer)
{
String first = tokenizer.nextToken();
if (first.equals("+")) {
@komamitsu
komamitsu / Command.txt
Created November 12, 2018 14:42
Calling Fluency from C using GraalVM:SubstrateVM
$ javac -cp fluency-1.9.0-SNAPSHOT-shadow.jar org/komamitsu/fluencycaller/FluencyCaller.java
$ native-image --class-path fluency-1.9.0-SNAPSHOT-shadow.jar:. --shared -H:Name=libfluency --verbose
$ cc -Wall -I. -L. -lfluency main.c
$ ./a.out
package com.mygdx.game;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
@komamitsu
komamitsu / komamitsu.json
Last active February 27, 2019 01:48
Karabiner-Elements Config
{
"title": "Komamitsu's configuration",
"rules": [
{
"description": "Internal US keyboard (1452/632): Post option if left_control is pressed.",
"manipulators": [
{
"type": "basic",
"conditions": [
{
import org.rocksdb.EnvOptions;
import org.rocksdb.FlushOptions;
import org.rocksdb.IngestExternalFileOptions;
import org.rocksdb.Options;
import org.rocksdb.OptionsUtil;
import org.rocksdb.RocksDB;
import org.rocksdb.SstFileWriter;
public class RocksDBTest
{
@komamitsu
komamitsu / gist:baa92b5dbd270f21938e55c97f00c350
Last active April 27, 2018 00:33
io.digdag.core.workflow.WorkflowExecutorTest#retryOnGroupingTask at jackson-2_8_11 branch
io.digdag.core.agent.OperatorManager#runWithWorkspace
Config localConfig = config.getFactory().create();
for (String localKey : request.getLocalConfig().getKeys()) {
>>> localConfig.set(localKey, config.getOptional(localKey, JsonNode.class).transform(JsonNode::deepCopy).orNull());
}
ex = {java.lang.ClassCastException@5548} "java.lang.ClassCastException: java.lang.String cannot be cast to com.fasterxml.jackson.databind.JsonNode"
detailMessage = "java.lang.String cannot be cast to com.fasterxml.jackson.databind.JsonNode"
cause = {java.lang.ClassCastException@5548} "java.lang.ClassCastException: java.lang.String cannot be cast to com.fasterxml.jackson.databind.JsonNode"