Skip to content

Instantly share code, notes, and snippets.

View NorioKobota's full-sized avatar
😘
Enjoy!

Norio Kobota NorioKobota

😘
Enjoy!
View GitHub Profile
@NorioKobota
NorioKobota / gist:e473a2884be8904f1a45
Created September 15, 2015 09:03
linear-cpp echo server
#include <iostream>
#include "linear/ws_server.h"
namespace app {
class Handler : public linear::Handler {
void OnMessage(const linear::Socket& socket, const linear::Message& message) {
switch (message.type) {
case linear::Request:
linear::Request request = message.as<linear::Request>();
<!DOCTYPE html>
<html>
<head>
<title>echo client</title>
<script type="text/javascript" src="./jquery.min.js"></script>
<script type="text/javascript" src="./linear.debug.js"></script>
<script type="text/javascript">
var c;
window.onload = function() {
@NorioKobota
NorioKobota / index.html
Last active October 16, 2015 06:34
exchange binary data between C++ and JavaScript by using linear-rpc - JS part(html)
<!--
$ git clone --recursive https://github.com/linear-rpc/linear-js /path/to
$ cp /path/to/linear-js/src/linear.min.js .
$ cp /this/index.html ./index.html
$ open ./index.html # with browser
==> check developer console
-->
<!DOCTYPE html>
<html>
<head>
@NorioKobota
NorioKobota / foo.cpp
Created October 16, 2015 06:33
exchange binary data between C++ and JavaScript by using linear-rpc - C++ part
/**
* $ git clone --recursive https://github.com/linaer-rpc/linear-cpp /path/to
* $ cd /path/to/linear-cpp
* $ ./bootstrap && ./configure && make
* $ cp /this/foo.cpp /path/to/linear-cpp/sample
* $ cd sample
* $ g++ -I ../include -I ../deps/msgpack/include -o foo foo.cpp ../src/.libs/liblinear.a ../deps/libtv/src/.libs/libtv.a ../deps/libtv/deps/libuv/.libs/libuv.a
* $ ./foo
*/
@NorioKobota
NorioKobota / msgpack_bin.cpp
Last active July 12, 2016 12:32
Dealing with msgpack easily on C++
// NOTE: linear-cpp/include/any.h, binary.h, optional.h are header only.
// $ git clone --recursive https://github.com/linear-rpc/linear-cpp
// $ clang++ msgpack_bin.cpp -I linear-cpp/deps/msgpack/include -I linear-cpp/include -std=c++11
// $ ./a.out fname # create a msgpack binary file
// $ cat fname | ./a.out # dump it
#include <fstream>
#include <iostream>