Skip to content

Instantly share code, notes, and snippets.

@brycebaril
brycebaril / output.md
Last active February 23, 2020 22:35
process.nextTick vs setImmediate

@mafintosh asks: "Does anyone have a good code example of when to use setImmediate instead of nextTick?"

https://twitter.com/mafintosh/status/624590818125352960

The answer is "generally anywhere outside of core".

process.nextTick is barely asynchronous. Flow-wise it is asynchronous, but it will trigger before any other asynchronous events can (timers, io, etc.) and thus can starve the event loop.

In this script I show a starved event loop where I just synchronously block, use nextTick and setImmediate

require 'webrick'
require 'webrick/https'
require 'ds9'
class HTTP2Server < WEBrick::HTTPServer
SETTINGS = [ [DS9::Settings::MAX_CONCURRENT_STREAMS, 100] ]
class HTTP2Response < WEBrick::HTTPResponse
def initialize config, ctx, stream_id
@ctx = ctx
@voluntas
voluntas / yunagido.rst
Last active December 24, 2018 07:43
夕凪堂コトハジメ
@tenderlove
tenderlove / h2_puma.rb
Last active August 14, 2024 06:10
Demo HTTP/2 server with Puma
require 'socket'
require 'openssl'
require 'puma/server'
require 'ds9'
class Server < DS9::Server
def initialize socket, app
@app = app
@read_streams = {}
@write_streams = {}
@azu
azu / Incremental DOM.md
Last active July 13, 2022 16:07
Incremental DOM ざっと見たやつ。追記: 初期バージョンのコードなので最新では異なる場合があります。

Incremental DOM

Introducing Incremental DOM — Google Developers — Medium

Reactやvirtual-dom、Glimmer(Ember)などVirtual DOMの実装は色々あるが、これらのVirtual DOM実装には2つの問題がある

  • 既存のテンプレート言語を利用していない(しにくい)
  • モバイルでのパフォーマンス、特にメモリに関しては大きすぎる

これらを解決するためにIncremental DOMと言うものを作っている(WIP)

require 'socket'
require 'openssl'
require 'puma/server'
require 'ds9'
class Server < DS9::Server
def initialize socket, app
@app = app
@read_streams = {}
@write_streams = {}
@shunsugai
shunsugai / read-fingerprint-service.txt
Created June 29, 2015 12:52
FingerprintServiceを読んで気になったこと
http://tools.oesf.biz/android-MNC/xref/com/android/server/fingerprint/FingerprintService.java
=====
532 @Override
533 // Binder call
534 public void authenticate(final IBinder token, final long opId, final int groupId,
535 final IFingerprintServiceReceiver receiver, final int flags, String opPackageName) {
536 checkPermission(USE_FINGERPRINT);
537 if (!canUserFingerPrint(opPackageName)) {
538 return;
539 }
@kgmyshin
kgmyshin / Android MのPermissionの個別設定情報の保存場所について
Last active August 29, 2015 14:23
Android MのPermissionの個別設定情報の保存場所について
Permissionのファイルは
/data/system/users/{userId}/runtime-permissions.xml
ここにこういうのが入ってる
```runtime-permissions.xml
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<runtime-permissions>
<pkg name="com.android.launcher">
@azu
azu / async-await-observable.md
Last active November 13, 2015 09:57
async/await、Rx、observableのECMAScript近況