Skip to content

Instantly share code, notes, and snippets.

@peerreynders
peerreynders / index.js
Created April 21, 2018 19:03
RxJS in Action Ch10 5B: Building the application
// file: src/index.js - Derived from:
// RxJS in Action (2017, Manning), 978-1-617-29341-2
// by Paul P. Daniels and Luis Atencio
// Listings:
// 10.6 Plugging into the middleware (p.297)
// 10.7 Implementing custom ofType operator (p.299)
// 10.8 Building your middleware (p.299)
// 10.9 Building the application (p.302)
//
// Variation B:
@peerreynders
peerreynders / index.js
Created April 21, 2018 19:07
RxJS in Action Ch10 5C: Building the application
// file: src/index.js - Derived from:
// RxJS in Action (2017, Manning), 978-1-617-29341-2
// by Paul P. Daniels and Luis Atencio
// Listings:
// 10.6 Plugging into the middleware (p.297)
// 10.7 Implementing custom ofType operator (p.299)
// 10.8 Building your middleware (p.299)
// 10.9 Building the application (p.302)
//
// Variation C: Eliminate Redux using only RxJS
@peerreynders
peerreynders / AddressInput.js
Created October 22, 2018 14:21
gen-browser Pinger/Ponger refactor - no async await
// file: src/AddressInput.js
import {getPropPathValue} from './Misc';
// --- DOM hook
const _addressInput = document.querySelector('main input[type="text"]');
function selectAddress(event) {
const name = getPropPathValue(event, ['target','constructor','name'], null);
if(name == 'HTMLInputElement') {
event.target.select();
@peerreynders
peerreynders / AddressInput.js
Created October 24, 2018 01:16
gen-browser Pinger/Ponger refactor part 2 - enter RxJS 6
// file: src/AddressInput.js
import {getPropPathValue} from './Misc';
// --- DOM hook
const _addressInput = document.querySelector('main input[type="text"]');
function selectAddress(event) {
const name = getPropPathValue(event, ['target','constructor','name'], null);
if(name == 'HTMLInputElement') {
event.target.select();
@peerreynders
peerreynders / Misc.js
Last active October 25, 2018 13:47
gen-browser Pinger/Ponger refactor part 3 - RxJS 6 on Top of EventSource
// file: src/Misc.js
export const PING = 'ping';
export const PONG = 'pong';
export function now() {
return new Date().toLocaleTimeString();
}
export function toTextFrom(from) {
@peerreynders
peerreynders / quickshot.html
Created October 25, 2018 14:00
gen_browser quickshot
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Quickshot</title>
</head>
<body>
<p>Open the Console!</p>
<p>
<ul>
@peerreynders
peerreynders / ServerEvents.js
Created October 30, 2018 16:18
gen-browser Pinger/Ponger refactor part 4 - Using RxJS fromEvent, using, etc. to remove some boilerplate
/*
file: src/ServerEvents.js
Previous:
- part 3: https://gist.github.com/peerreynders/d59d37dd47016a932ee9c786e3817560
- part 2: https://gist.github.com/peerreynders/a0965c47cce31fb6a6677b90f0ca71cc
- part 1: https://gist.github.com/peerreynders/474145762df0708fe78bf39b548fab00
see also: https://gist.github.com/peerreynders/412911579e4a0c485f67a122634cffe2
@peerreynders
peerreynders / from_pipe.ex
Created December 18, 2018 21:26
Elixir port using named pipe with forwarding script
defmodule FromPipe do
#
# Use a helper script "from_pipe_forward" to communicate
# contents from the named pipe to the port
#
@pipe_name "/tmp/testpipe"
@from_pipe_forward "./from_pipe_forward"
@from_pipe_clean "./from_pipe_clean"
# * terminate potential zombie OS process
@peerreynders
peerreynders / from_pipe.ex
Last active March 29, 2023 18:36
Elixir port using named pipe with releasing script
defmodule FromPipe do
#
# Use a helper script "from_pipe_release" to
# release/request each line read from the
# named pipe - effectively implementing a
# crude backpressure mechanism
#
@pipe_name "/tmp/testpipe"
@from_pipe_release "./from_pipe_release"
@from_pipe_clean "./from_pipe_clean"
@peerreynders
peerreynders / from_pipe.ex
Created December 18, 2018 21:46
Elixir port using named pipe via UNDOCUMENTED open_port/2 functionality
defmodule FromPipe do
#
# NOTE: this use of ports is based on UNDOCUMENTED functionality
# of the open_port/2 function - i.e. could stop working
# in any future release
# http://erlang.org/doc/man/erlang.html#open_port-2
#
# See also:
# Erlang and Named Pipes
# https://gist.github.com/jaredmorrow/1c342c6e9156eddd20b2