Skip to content

Instantly share code, notes, and snippets.

/*
Install this hook in app.hooks.js
module.exports = app => {
app.hooks({
before: {
all: [
addParamsForward()
]
}
@KidkArolis
KidkArolis / _intro.md
Last active March 16, 2020 13:22
Feedback on `useMutableSource`

Dear reader,

In the last few years, I've been using my own global store implementation with great success (yes, I'm aware there exist a bazillion "redux like" stores). My one's called tiny-atom.

In particular, the following 4 requirements for a global store emerged from my needs:

1. Batch multiple, rapid store changes

For example, tiny-atom uses requestAnimationFrame to delay/batch the re-renders.

@KidkArolis
KidkArolis / feathers.js
Created November 20, 2019 17:24
Feathers Client with robust reauthentication
import createFeathersClient from '@feathersjs/feathers'
import auth from '@feathersjs/authentication-client'
import socketio from '@feathersjs/socketio-client'
import io from 'socket.io-client'
export function createFeathers() {
const socket = io()
const feathers = createFeathersClient()
feathers.configure(socketio(socket))
feathers.configure(
@KidkArolis
KidkArolis / post.md
Last active November 17, 2020 11:21
Designing custom React hooks - sequencing of async effects

We've been building a hooks based REST API wrapper.

A specific use case discussed in this gist is – how do you close a modal after updating a remote resource completes succesfully?

Which of the following options seems best or is there a better approach altogether?

1. Async/Await

function EditNoteModal ({ id, onClose }) {
@KidkArolis
KidkArolis / default.yml
Created February 9, 2019 13:01
node-config example
port: 3000
session:
secret: abc
fitbit:
protocol: http
host: localhost:3000
clientId: a
clientSecret: b
@KidkArolis
KidkArolis / Dockerfile
Last active December 13, 2018 13:55
Countly on DigitalOcean
FROM countly/countly-server
@KidkArolis
KidkArolis / actions.js
Created November 21, 2018 14:34
Fetch and take latest
import axios from 'axios'
import fetch from './fetch'
export default {
async fetchPage ({ dispatch }, { query, headers }, ref) {
// every time this action is dispatched, make the request using the fetch helper
// which ensures we cancel previous requests and only mutate state after the latest one
await fetch(ref, {
request: cancelToken => {
return Promise.all(
[Unit]
Description=Playe Controller
[Service]
ExecStart=/usr/bin/node /home/pi/play/play-controller/controller.js
Restart=always
RestartSec=5
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=play-controller
'use strict'
let express = require('express')
let axios = require('axios')
let server
function once (cb) {
let app = express()
app.get('/foo', (req, res, next) => {
var grep = require('karma-webpack-grep')
var webpackConfig = require('./webpack.config')
module.exports = function (config) {
webpackConfig.plugins = (webpackConfig.plugins || []).concat(grep({
grep: config.grep,
basePath: '.',
testContext: './tests'
}))