Skip to content

Instantly share code, notes, and snippets.

@panchaow
panchaow / xxf.zsh-theme
Created June 21, 2019 16:31 — forked from xfanwu/xxf.zsh-theme
Yet another theme for oh-my-zsh
# Copy and self modified from ys.zsh-theme, the one of default themes in master repository
# Clean, simple, compatible and meaningful.
# Tested on Linux, Unix and Windows under ANSI colors.
# It is recommended to use with a dark background and the font Inconsolata.
# Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
# http://xiaofan.at
# 2 Jul 2015 - Xiaofan
# Machine name.
function box_name {
@panchaow
panchaow / file-input.js
Created April 20, 2018 15:02
File input in React
// https://reactjs.org/docs/uncontrolled-components.html#the-file-input-tag
class FileInput extends React.Component {
constructor(props) {
super(props);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleSubmit(event) {
event.preventDefault();
alert(
`Selected file - ${this.fileInput.files[0].name}`
@panchaow
panchaow / refs.js
Created April 20, 2018 14:16
new Refs API in React
class MyComponent extends React.Component {
constructor(props) {
super(props);
// Refs are created using React.createRef().
// Refs are commonly assigned to an instance property when a component is constructed so they can be referened throughout the component.
this.myRef = React.createRef();
}
render() {
// Refs are attached to React elements via the ref attribute
return <div ref={this.myRef} />;