Skip to content

Instantly share code, notes, and snippets.

View futurist's full-sized avatar

James Yang futurist

  • China
View GitHub Profile
@futurist
futurist / curl-websocket.sh
Created September 16, 2020 10:22 — forked from htp/curl-websocket.sh
Test a WebSocket using curl.
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/

macOS:10.13.6 MacBook Pro (13-inch, Early 2011) TIME: 2020/08/10

rocket 110.44ms 4830.54

tide 72.26ms 6072.79

warp 51.66ms 7443.28

gotham 45.64ms 9502.72

@futurist
futurist / 从Node到Deno.md
Last active October 31, 2023 14:11
从Node到Deno

从Node到Deno,你需要知道的

* 第一部分:安装

以MacOS系统为例,说明安装的不同

A. Node安装

涉及的文件:node, npm, npx, node_modules 文件夹

rustup component add rust-src
export RUST_SRC_PATH="$(rustc --print sysroot)/lib/rustlib/src/rust/src"
@futurist
futurist / JSIObject.cpp
Created April 23, 2020 08:29 — forked from axemclion/JSIObject.cpp
React Native JSI Example
// This sample is a Work in Progress for JSI , and specific functions may change.
#pragma once
#include <string>
#include <unordered_map>
#include <jsi/jsi.h>
// This SameplJSIObject needs to inheric from HostObject, and this is the object that will be exposed to JS.
function arrayKV (obj, k, v, reverse, unique) {
let prevVal = _.get(obj, k)
if(!Array.isArray(prevVal)) {
prevVal = prevVal === undefined ? [] : [prevVal]
_.set(obj, k, prevVal)
}
if (unique && prevVal.indexOf(v) > -1) return
return reverse ? prevVal.unshift(v) : prevVal.push(v)
}
@futurist
futurist / test.ipynb
Last active September 24, 2018 07:02
jupyter notebooks
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@futurist
futurist / hc-bee-hot-reload.js
Created July 25, 2018 08:50
hc-bee with SSE Hot reload
// honeypack: middleware.js
// LINE 69
middleware.waitUntilValid(stats=>{
app.emit('webpack.valid', stats)
})
// app.js
const Honeybee = require('hc-bee');
const app = new Honeybee();
@futurist
futurist / nested-component.js
Created July 24, 2018 02:20
Meiosis nested component
/**
<script src="https://unpkg.com/patchinko/overloaded.js"></script>
<script src="https://unpkg.com/mithril-stream"></script>
<script src="https://unpkg.com/react/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom/umd/react-dom.development.js"></script>
<div id=APP></div>
<script src="index.js"></script>
*/