Skip to content

Instantly share code, notes, and snippets.

View cheton's full-sized avatar
🎯

Cheton Wu cheton

🎯
View GitHub Profile
@cheton
cheton / proxy-server.js
Last active January 26, 2018 02:45
Proxy Server
#!/usr/bin/env node
const path = require('path');
const bin = path.basename(process.argv[1]);
const chalk = require('chalk');
const debug = require('debug')(bin);
const program = require('commander');
const httpProxy = require('http-proxy');
@cheton
cheton / objectKeysToLowerCase.js
Created December 19, 2017 14:17
Turn all the keys of an object to lower case
//
// https://stackoverflow.com/questions/12539574/whats-the-best-way-most-efficient-to-turn-all-the-keys-of-an-object-to-lower/12540603#12540603
//
/** @summary objectKeysToLowerCase( input, deep, filter )
* returns a new object with all own keys converted to lower case.
* The copy can be shallow (default) or deep.
*
* Circular references is supported during deep copy and the output will have
* the same structure.
*
@cheton
cheton / cap-generator.scad
Last active February 24, 2018 12:36
OpenSCAD
// Cap Generator
// https://www.thingiverse.com/thing:1943463/#files
/*----------------------------------------------------------------------------*/
/* Cap Generator
/* by Ziv Botzer
/*----------------------------------------------------------------------------*/
// Turn on for validation during preview, TURN OFF FOR PRODUCTION
show_slice = "On"; // [On, Off]
@cheton
cheton / readable-size.js
Last active June 29, 2018 07:13
Converts bytes into human readable size units.
const units = [
'B',
'KB',
'MB',
'GB',
'TB',
'PB',
'EB',
'ZB',
'YB',
@cheton
cheton / find-raspberry.sh
Created July 3, 2018 06:26 — forked from niun/find-raspberry.sh
Find Raspberry Pi in network (looking for MAC address vendor prefix of Raspberry Pi Foundation using nmap, awk for ipv4 / ping6, ip, grep for ipv6 neighbour discovery)
sudo nmap -sP 192.168.0.0/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}'
@cheton
cheton / particulate-matter.js
Last active July 3, 2018 16:17
A Particulate Matter Detector Using PM 2.5 Sensor by PLANTOWER
//
// http://aqicn.org/air/view/sensor/spec/pms7003.pdf
//
const SerialPort = require('serialport');
const port = new SerialPort('/dev/ttyUSB0', {
baudRate: 9600
});
# GRBL Source (The standard GRBL firmware is identaical to the Inventables GRBL, just some minor config changes.)
https://github.com/gnea/grbl
Compiled with settings:
[Changes to (config.h)]
#define DEFAULTS_X_CARVE_1000MM
#define HOMING_FORCE_SET_ORIGIN // Enabled
#define ENABLE_M7 // Enabled
#define ENABLE_SAFETY_DOOR_INPUT_PIN // Enabled
@cheton
cheton / expose-cards-timeout.js
Last active August 3, 2018 16:56
Expose Cards w/ Timeout
require('babel-core/register');
require('babel-polyfill');
const timeout = (ms) => new Promise((resolve, reject) => {
setTimeout(() => reject(new Error(`Timeout exceeded: ${ms}ms`)), ms);
});
class Player {}
class AsyncAction {
@cheton
cheton / Parallelogram.jsx
Last active November 21, 2018 13:23
Parallelogram
import React from 'react';
import styled, { css } from 'styled-components';
const Component = styled.div`${({
width,
height,
before,
beforeBorderMask,
beforeBorderColor,
beforeBackgroundColor,
@cheton
cheton / Carousel.jsx
Created November 21, 2018 13:24
Carousel