Slide 1

Slide 1 text

I’m @aq HELLO!

Slide 2

Slide 2 text

5 facts about @aq

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Follow @catskillsconf Oct 23-25

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Ruby, JS, Go Performance etc but you can hire me!

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

The Story of a Yak Shave

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Some node.js options:

Slide 11

Slide 11 text

not precise or 1:1; poor font handling node-canvas

Slide 12

Slide 12 text

almost there, but more geared to GUI applications node-webkit

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

Have the ability to reuse existing code and knowledge about production I wanted to see if go was possible

Slide 15

Slide 15 text

aka Chromium Embedded Framework Enter and cef2go

Slide 16

Slide 16 text

chromium C & C++ API cef2go (cgo)

Slide 17

Slide 17 text

C & C++ API cef2go your go app your js app Service Request/ Response chromium JS Exec/ Response

Slide 18

Slide 18 text

1 for i := 0; i < 3; i++ { 2 browser := cef.CreateBrowser(browserSettings, url, true) 3 browser.ExecuteJavaScript("console.log('we outchea');", "sup.js", 1) 4 } 5

Slide 19

Slide 19 text

3 browser.ExecuteJavaScript("console.log('we outchea');", "sup.js", 1)

Slide 20

Slide 20 text

github.com/paperlesspost/chromefarm Solve it with AJAX

Slide 21

Slide 21 text

2 10 func main() { 12 farm := chromefarm.NewFarm() 14 // This serves the postback.html for the browser to load 15 http.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) { 17 http.ServeFile(res, req, "postback.html") 18 }) 19 // this handles the callback from JS/AJAX 20 http.HandleFunc("/callback", func(res http.ResponseWriter, req *http.Request) { 21 message := req.FormValue("message") 22 log.Println("Received message from browser: %s", message) 25 }) 26 farm.OnReady(func() { 29 for i := 0; i < 2; i++ { 30 browser := farm.CreateBrowser(url) 31 browser.ExecuteJavaScript(fmt.Sprintf("console.log('sup %d');", i), "eva 32 } 33 }) 34 farm.Start(":3000") 36 } 7 8 9 $.post('/callback', {message: "I've loaded successfully"}, function(resp) { 10 console.log(resp); 11 }); 12 13

Slide 22

Slide 22 text

This has to get MORE awesome Hmmm

Slide 23

Slide 23 text

24 extCode := ` 25 var cef2go; 26 if (!cef2go) { 27 cef2go = {}; 28 } 29 (function() { 30 cef2go.callback = function() { 31 native function callback(); 32 return callback.apply(this, arguments); 33 } 34 })(); 35 ` 36 C.cef_register_extension(CEFString("v8/cef2go"), CEFString(extCode), handler)

Slide 24

Slide 24 text

C C

Slide 25

Slide 25 text

cef.callback('myGoCallback', "any", "type", 0, "args", true)

Slide 26

Slide 26 text

1 // cef.callback('myGoCallback', "any", "type", 0.0, 13, true) 2 cef.RegisterV8Callback("myGoCallback", cef.V8Callback(func(args []*cef.V8Value) { 3 arg0 := args[0].ToString() //=> "any" 4 arg1 := args[1].ToString() //=> "type" 5 arg2 := args[2].ToFloat32() //=> 0.0 6 arg3 := args[3].ToInt32() //=> 13 7 arg4 := args[4].ToBool() //=> true 8 // I'm in go now #yolo 9 })) 10

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

BUt WHY?!

Slide 29

Slide 29 text

Or a JS app that takes advantage of Go’s concurrency + tools A Go app that makes use of the browser + JS

Slide 30

Slide 30 text

I mean the real reason is because its an epic and beautiful hack.

Slide 31

Slide 31 text

@aq quirkey.com github.com/quirkey THANKS