Skip to content

Instantly share code, notes, and snippets.

View CYBAI's full-sized avatar
🇹🇼
λf. (λx. f (x x)) (λx. f (x x))

cybai (Haku) CYBAI

🇹🇼
λf. (λx. f (x x)) (λx. f (x x))
View GitHub Profile
@CYBAI
CYBAI / esm_in_node_proposal.md
Created January 13, 2018 08:13 — forked from ceejbot/esm_in_node_proposal.md
npm's proposal for supporting ES modules in node

ESM modules in node: npm edition

JavaScript in browsers has a new module system: ES modules. JavaScript in node.js has had a module system for years: CommonJS modules. JavaScript developers have nearly universally adopted node as the platform of choice for their tooling. Web application frameworks all use command-line tools written in node, pulling shared code from the npm registry, to build applications that run on the browser. Open-source code they find on npm is freely used in these applications. Browser app developers now have the following expectations:

  • Code they write for their tooling uses the same language as their browser applications.
  • Code they discover in npm's module registry is re-usable in the browser.

CommonJS modules do not work in the browser, but bundling tools like browserify and webpack have allowed CommonJS modules to be built into browser-ready code. Early implementations of ES modules rely on the CommonJS module system under the hood, as Babel transpiles ESM syntax into Common

@CYBAI
CYBAI / tokio-internals.md
Created January 14, 2018 08:23 — forked from weihanglo/tokio-internals.md
【譯】Tokio 內部機制:從頭理解 Rust 非同步 I/O 框架

本文譯自 [Tokio internals: Understanding Rust's asynchronous I/O framework from the bottom up][tokio-internals]。
Thanks [David Simmons][david-simmons] for this awesome article!

[Tokio][tokio] 是 Rust 的開發框架,用於開發非同步 I/O 程式(asynchronous I/O,一種事件驅動的作法,可實現比傳統同步 I/O 更好的延伸性、效能與資源利用)。可惜的是,Tokio 過於精密的抽象設計,招致難以學習的惡名。即使我讀完教程後,依然不認為自己充分內化這些抽象層,以便推斷實際發生的事情。

從前的非同步 I/O 相關開發經驗甚至阻礙我學習 Tokio。我習慣使用作業系統提供的 selection 工具(例如 Linux epoll)當作起點,再轉移至 dispatch、state machine 等等。倘若直接從 Tokio 抽象層出發,卻沒有清楚了解 epoll_wait() 在何處及如何發生,我會覺得難以連結每個概念。Tokio 與 future-driven 的方法就好像一個黑盒子。

@CYBAI
CYBAI / tutorial.md
Created June 17, 2018 02:53 — forked from swalkinshaw/tutorial.md
Designing a GraphQL API

Tutorial: Designing a GraphQL API

This tutorial was created by Shopify for internal purposes. We've created a public version of it since we think it's useful to anyone creating a GraphQL API.

It's based on lessons learned from creating and evolving production schemas at Shopify over almost 3 years. The tutorial has evolved and will continue to change in the future so nothing is set in stone.

@CYBAI
CYBAI / build-llvm.bash
Created September 16, 2018 09:42 — forked from zchee/build-llvm.bash
Build llvm for OS X
#!/bin/bash
set -e
# Building LLVM on OSX CMake setup script
#
# Required:
# - clang by Xcode6 or later
# - cmake
# - ninja
#
@CYBAI
CYBAI / prism-textarea.js
Created June 29, 2016 17:06
[WIP] Make `textarea` syntax highlight
var script = document.createElement('script');
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.1/prism.js';
document.body.appendChild(script);
var csslink = document.createElement('link');
csslink.setAttribute('rel', 'stylesheet');
csslink.setAttribute('type', 'text/css');
csslink.setAttribute('href', 'https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.1/themes/prism-solarizedlight.css');
document.getElementsByTagName('head')[0].appendChild(csslink);

Keybase proof

I hereby claim:

  • I am cybai on github.
  • I am cybai (https://keybase.io/cybai) on keybase.
  • I have a public key ASAKGCR8xr2NhsKcsW2xJCrrjEUhWBsmv7jMBXVY1vhKIwo

To claim this, I am signing this object:

@CYBAI
CYBAI / reduce-css.js
Created March 22, 2019 10:48 — forked from emilio/reduce-css.js
Ever wanted to reduce all the CSS in a test-case to the minimmum? :)
var USELESS_PROPERTIES = [];
function processContainer(container) {
if (container instanceof CSSSupportsRule)
if (!CSS.supports(container.conditionText))
return false;
if (container instanceof CSSMediaRule)
if (!matchMedia(container.conditionText).matches)
return false;
if (container.media && container.media.mediaText)
@CYBAI
CYBAI / chapter3.purs
Last active June 16, 2019 01:22
PureScript By Example Exercises
module Exercise where
import Prelude
import Data.AddressBook
import Data.Functor ((<$>))
import Data.List (filter, head, null, nubBy)
import Data.Maybe (Maybe)
-- 1.