Skip to content

Instantly share code, notes, and snippets.

Avatar

Sadayuki Furuhashi frsyuki

View GitHub Profile
View doorkeeper-solve-distributed-race-condition
Example:
* (00:01:01): Initial state: client stores access_token=a01 and refresh_token=r01.
API DB access_tokens table is as following:
| access_token | refresh_token | previous_refresh_token | expires_in | created_at | revoked_at |
| a01 | r01 | | 3605 | 00:00:01 | |
* (00:02:02): Client refreshes token using refresh_token=r01.
It gets access_token=a02 and refresh_token=r02.
View kafka-ksql-msgpack.patch
diff --git a/ksql-core/pom.xml b/ksql-core/pom.xml
index afa072a..0a889b0 100644
--- a/ksql-core/pom.xml
+++ b/ksql-core/pom.xml
@@ -44,6 +44,11 @@
</dependency>
<dependency>
+ <groupId>org.msgpack</groupId>
+ <artifactId>msgpack-core</artifactId>
View msgpack-ruby-frozen-str-cache.diff
diff --git a/ext/msgpack/buffer.h b/ext/msgpack/buffer.h
index 9387254..5c8af67 100644
--- a/ext/msgpack/buffer.h
+++ b/ext/msgpack/buffer.h
@@ -20,6 +20,7 @@
#include "compat.h"
#include "sysdep.h"
+#include "frozen_str_cache.h"
View MethodTypeCheckable-experimental.rb
module HasSize
def size
end
end
module MethodTypeCheckable
def method_type_check(name, signature)
origin = self.instance_method(name)
define_method(name) do |*args, &block|
View expand_json-type-convert-from-float-to-long.patch
diff --git a/src/main/java/org/embulk/filter/expand_json/FilteredPageOutput.java b/src/main/java/org/embulk/filter/expand_json/FilteredPageOutput.java
index afb2884..1148e54 100644
--- a/src/main/java/org/embulk/filter/expand_json/FilteredPageOutput.java
+++ b/src/main/java/org/embulk/filter/expand_json/FilteredPageOutput.java
@@ -329,7 +329,13 @@ public class FilteredPageOutput
pageBuilder.setLong(expandedJsonColumn.getColumn(), Long.parseLong(finalValue));
}
catch (NumberFormatException e) {
- throw new JsonValueInvalidException(String.format("Failed to parse '%s' as long", finalValue), e);
+ // ad-hoc workaround for exponential notation
View LambdaJitTrace.java
import java.util.function.Function;
import java.util.function.ToIntFunction;
public class LambdaJitTrace
{
public static void main(String[] args)
{
Function<String, String> trim = (x) -> x.trim();
Function<String, String> trimDup = (x) -> trim.apply(x) + trim.apply(x);
ToIntFunction<String> trimDupSize = (x) -> trimDup.apply(x).length();
View jmap-help-1.txt
$ jmap
Usage:
jmap -histo <pid>
(to connect to running process and print histogram of java object heap
jmap -dump:<dump-options> <pid>
(to connect to running process and dump java heap)
dump-options:
format=b binary default
file=<file> dump heap to <file>
View cache_like.rb
# PoC user code
require_relative 'call_check'
class CacheLike
include CallCheck
def initialize(store, log)
@store = store
@log = log
View msgpack-ruby-fstring-hash-key-dedup-hack.diff
diff --git a/ext/msgpack/buffer.h b/ext/msgpack/buffer.h
index 9387254..bcbe99b 100644
--- a/ext/msgpack/buffer.h
+++ b/ext/msgpack/buffer.h
@@ -424,22 +424,61 @@ static inline VALUE _msgpack_buffer_refer_head_mapped_string(msgpack_buffer_t* b
return rb_str_substr(b->head->mapped_string, offset, length);
}
-static inline VALUE msgpack_buffer_read_top_as_string(msgpack_buffer_t* b, size_t length, bool will_be_frozen)
+#ifdef COMPAT_HAVE_ENCODING
View nashorn-weakref-leak.java
import java.util.Scanner;
import javax.script.*;
public class ScriptTest {
private static volatile boolean stop = false;
public static void main(String[] args) {
Thread t = new Thread(() -> runLoop());
t.start();