Skip to content

Instantly share code, notes, and snippets.

Sadayuki Furuhashi frsyuki

Block or report user

Report or block frsyuki

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View GraalPolyglot.java
import java.io.File;
import java.io.IOException;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Source;
import org.graalvm.polyglot.Value;
public class GraalPolyglot {
public static void main(String[] args) throws IOException {
Source source = Source.newBuilder("ruby", new File(args[0])).build();
View GraalPolyglot.java
import java.io.File;
import java.io.IOException;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Source;
import org.graalvm.polyglot.Value;
public class GraalPolyglot {
public static void main(String[] args) throws IOException {
Source source = Source.newBuilder("ruby", new File(args[0])).build();
View GraalPolyglot.java
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value;
public class GraalPolyglot {
public static void main(String[] args) {
try (Context context = Context.newBuilder().allowAllAccess(true).build()) {
Value v = context.eval("ruby", "'Ruby String'");
context.getBindings("js").putMember("v", v);
context.eval("js", "print('v=' + v)"); //=> v=Ruby String
}
View compiling-ruby-for-poc.sh
./configure \
$(ruby -e "puts RbConfig::CONFIG['configure_args']") \
CFLAGS=$(ruby -e "puts RbConfig::CONFIG['CFLAGS'] + ' -flto'") \
LDFLAGS=$(ruby -e "puts RbConfig::CONFIG['LDFLAGS'] + ' -flto'") \
--enable-shared \
--prefix=$(pwd)/install
View a-MJIT-LTO.md
require 'benchmark'
Benchmark.bmbm do |x|
  x.report("Array.push") do
    arrays = []
    1000.times do |i|
      arrays[i] = []
      (0...500000).each do |j|
        arrays[i] = j
      end
View result.md

No optimization:

        user     system      total        real
0.1kb   1.204809   0.005060   1.209869 (  1.210884)
1kb     1.309668   0.004896   1.314564 (  1.315971)
10kb    2.674302   0.077470   2.751772 (  2.755213)
100kb  29.982771  22.375113  52.357884 ( 52.386822)
500kb 122.625423  82.284026 204.909449 (205.018250)
600kb   1.006700   0.003676   1.010376 (  1.010782)
View rubykaigi2019-profiler.rb
require 'benchmark'
require 'json'
require 'yajl'
require 'msgpack'
here = File.dirname(File.expand_path(__FILE__))
# https://catalog.data.gov/dataset/consumer-complaint-database
VIEWS_OBJ = JSON.load(File.read("#{here}/views.json"))
VIEWS_MSGPACK = MessagePack.pack(VIEWS_OBJ)
View DigdagMultistageOperatorUtilityIdea.java
public class Multistage<P>
{
public static class State<T>
{
private Object nextLambdaArgument;
private boolean isNext;
private State(Object nextLambdaArgument, boolean isNext)
{
View Gemfile
source 'https://rubygems.org/'
gemspec
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.
You can’t perform that action at this time.