Skip to content

Instantly share code, notes, and snippets.

To make servers listen to connections on all network interfaces:
--bind all
@baranovxyz
baranovxyz / incoming$
Last active September 25, 2017 13:25
const incomingFG$ = outgoing$
.filter(isOkRequest)
.filter(({ method }) => method === "find" || method === "get")
.map(({ service, method, query, _namespace }) =>
xs.create({
start: listener => {
socket.emit(`${service}::${method}`, query, (error, response) => {
if (error) listener.error(error);
listener.next({
service,
/**
* To avoid null state
*/
export const NullableComponent = (
component: Component,
vnodeForNull: VNode | null = null,
componentSinks: Array<string> = ["DOM", "onion"]
) => (sources: Sources): Sinks => {
const t$ = sources.onion.state$.map(
state =>
module.exports = {
entry: {
main: [appPath("src", "index.ts"), appPath("src", "css", "styles.scss")]
},
output: {
filename: "bundle.[hash].js",
path: appPath("build")
},
devServer: {
historyApiFallback: {

Checklist to debug Cyclejs app

  • Check if sinks from app components connected to main app. May use .debug('sink name') on app sinks.
  • Check if .flatten() used on stream of streams that might return results async, maybe use .compose(flattenConcurrently) instead.

Errors

  • Uncaught TypeError: s[i]._add is not a function - often means that s[i] is not a stream and you forgot to return sink.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
function utf8ToBytes (str) {
// TODO(user): Use native implementations if/when available
var p = 0
var buf = new ArrayBuffer(str.length * 1.5) // fixme Use better algo?
var out = new Uint8Array(buf)
for (var i = 0; i < str.length; i++) {
var c = str.charCodeAt(i)
if (c < 128) {
out[p++] = c
} else if (c < 2048) {
@baranovxyz
baranovxyz / Map.vue
Last active October 30, 2021 13:46
Example of using datamaps with vuejs
<template>
<div class="map" :style="`height: ${height}px;`">
<svg ref="svg" class="map-container"
xmlns="http://www.w3.org/2000/svg"
:width="width" :height="height"
shape-rendering="geometricPrecision"
:viewBox="`500 100 200 400`"
>
</svg>
</div>
describe('The Initialization Form', () => {
beforeEach(() => {
cy.fixture('config.json').as('config')
indexedDB.deleteDatabase('localforage')
cy.server()
cy.route({
method: 'POST',
function updateState(dispatch) {
dispatch(SET_STATUS({ status: 'submitting' }));
return fetch('https://example.com/api/a')
.then(() => {
dispatch(SET_STATUS({ status: 'processing' }));
return fetch('https://example.com/api/b')
.then(response => {
return response
.json()