View yhara_webassembly.md

footer: RubyKaigi 2017 (19, Sep) slidenumbers: true autoscale: true

Ruby, Opal and WebAssembly

RubyKaigi2017

inline

yhara (Yutaka Hara)


View keymap.c
#include "ergodox.h"
#include "debug.h"
#include "action_layer.h"
#define BASE 0 // default layer
#define SYMB 1 // symbols
#define MDIA 2 // media keys
#define LOWER 3
#define RAISE 4
View foo
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.
__DIR__
=> File.dirname(__FILE__)
File.dirname
__DIR__("../foo")
=> File.expand_path("../foo", File.dirname(__FILE__))
View calls.txt
...............................
Finished in 17.36 seconds (files took 8.86 seconds to load)
31 examples, 0 failures
--- Called Methods ---
ActionView::LogSubscriber#initialize
ActionView::LogSubscriber.add_event_subscriber
ActionView::LogSubscriber.attach_to
ActionView::LogSubscriber.method_added
View ev3_led_patch.rb
#
# 以下のコードを読み込むと、Brickクラスのメソッドが追加されます。
#
# LEDを光らせる
# @brick.set_led(色)
# 色は0〜9の数値
# 例: @brick.set_led(6)
#
# 音を鳴らす
# @brick.play_tone(音量, 周波数, 長さ)
View ray.es
extern i32 putchar(i32);
extern double sqrt(double);
def clamp(t: Float, min: Float, max: Float) -> Float
if t < min
min
elsif t > max
max
else
t
View ray.es
extern i32 putchar(i32);
extern double sqrt(double);
class Vec
def initialize(@x: Float, @y: Float, @z: Float); end
def vsub(b: Vec) -> Vec
Vec.new(@x - b.x, @y - b.y, @z - b.z)
end
View ppm.es
extern i32 putchar(i32);
# P3\n
putchar(80); putd(3); putchar(10);
# W H\n
putd(256); putchar(32); putd(256); putchar(10);
# D
putd(255); putchar(10);
# Output a ppm image
View ray.rb
# 1. とりあえず色を出す
IMAGE_WIDTH = 256
IMAGE_HEIGHT = 256
IMAGE_DEPTH = 256
class Vec
def initialize(x, y, z)
@x, @y, @z = x, y, z
end
View syntax.js
(function(){
//
// Syntax
//
BiwaScheme.Syntax = BiwaScheme.Class.create({
initialize: function(sname, func){
this.sname = sname;
this.func = func;
},
transform: function(x){