Skip to content

Instantly share code, notes, and snippets.

View cheton's full-sized avatar
🎯

Cheton Wu cheton

🎯
View GitHub Profile
@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 / 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 / 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 / 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 / index.jsx
Last active September 18, 2017 04:31
Show a modal window on the topmost frame of the browser window
import 'trendmicro-ui/dist/css/trendmicro-ui.css';
import '@trendmicro/react-buttons/dist/react-buttons.css';
import { Button } from '@trendmicro/react-buttons';
import React, { PureComponent } from 'react';
import ReactDOM from 'react-dom';
import styled from 'styled-components';
import Navbar from './Navbar';
import Portal from '../src';
const StyledPortal = styled(Portal)`
<Widget widgetId="threats" />
// ES7 class properties
class Widget extends React.Component {
state = this.getInitialState(); // ?
getInitialState() {
return {
widgetId: this.props.widgetId
};
## Application Blocking
### ApplicationControl.jsx
```js
import PropTypes from 'prop-types';
import React, { PureComponent } from 'react';
import BlockedAppsModal from './BlockedAppsModal';
import {
MODAL_BLOCKED_APPS
} from './constants';
@cheton
cheton / Button.jsx
Last active November 22, 2016 02:31
Buttons
import classNames from 'classnames';
import React, { PropTypes } from 'react';
import styles from './index.styl';
const Button = (props) => {
const {
type = 'button',
children,
className,
componentClass,
.custom-scroll::-webkit-scrollbar {
-webkit-overflow-scrolling: touch;
height: 10px;
width: 10px
}
.custom-scroll::-webkit-scrollbar:hover {
background-color: #E9E9E9;
border: 1px solid #dbdbdb
}
import omit from 'lodash/omit';
import React, { Component, PropTypes } from 'react';
const REGEXP = /{{(.+?)}}/;
class Interpolate extends Component {
static defaultProps = {
parent: 'span'
};