Skip to content

Instantly share code, notes, and snippets.

I may be slow to respond.

Cheton Wu cheton

I may be slow to respond.
View GitHub Profile
View distributed-mediasoup.js
onServerStartup () {
const { serverId, ip } = getServerInfo() // serverId does not change across restarts
this.serverId = serverId
// We don't have any routers or producers (yet). Clear any value that exists in the DB related to our serverId
clearSharedDB(serverId, 'routers')
clearSharedDB(serverId, 'producers')
// Update the DB with our serverId and ip so that others will know how to reach us
registerServerInDB(serverId, ip)
View machine.js
const fetchMachine = Machine({
id: 'fetchMachine',
initial: 'idle',
context: {
isFetchedOnce: false,
isFetching: false,
data: null,
error: null,
states: {
View init.vim
" Convert new tabs to spaces
set expandtab
set shiftwidth=4
set softtabstop=4
set tabstop=4
" No end of line
set noeol
call plug#begin()
cheton / theme-preset.js
Last active Dec 27, 2019
(Draft) Trend Micro Frontend Theme
View theme-preset.js
const breakpoints = [
// @media screen and (min-width: 320px)
// @media screen and (min-width: 640px)
// @media screen and (min-width: 1024px)
View Carousel.jsx
cheton / Parallelogram.jsx
Last active Nov 21, 2018
View Parallelogram.jsx
import React from 'react';
import styled, { css } from 'styled-components';
const Component = styled.div`${({
cheton / expose-cards-timeout.js
Last active Aug 3, 2018
Expose Cards w/ Timeout
View expose-cards-timeout.js
const timeout = (ms) => new Promise((resolve, reject) => {
setTimeout(() => reject(new Error(`Timeout exceeded: ${ms}ms`)), ms);
class Player {}
class AsyncAction {
View X-Carve GRBL-1.1f Settings.txt
# GRBL Source (The standard GRBL firmware is identaical to the Inventables GRBL, just some minor config changes.)
Compiled with settings:
[Changes to (config.h)]
#define HOMING_FORCE_SET_ORIGIN // Enabled
#define ENABLE_M7 // Enabled
cheton / particulate-matter.js
Last active Jul 3, 2018
A Particulate Matter Detector Using PM 2.5 Sensor by PLANTOWER
View particulate-matter.js
const SerialPort = require('serialport');
const port = new SerialPort('/dev/ttyUSB0', {
baudRate: 9600