Skip to content

Instantly share code, notes, and snippets.

Avatar

Yosuke Saito saitoxu

View GitHub Profile
@saitoxu
saitoxu / commands.sh
Last active Mar 22, 2018
how to install node_exporter (CentOS 7.4)
View commands.sh
$ sudo su -
$ cd /opt
$ wget https://github.com/prometheus/node_exporter/releases/download/v0.15.2/node_exporter-0.15.2.linux-amd64.tar.gz
$ tar xzvf node_exporter-0.15.2.linux-amd64.tar.gz
$ mv node_exporter-0.15.2.linux-amd64.tar.gz /usr/local/src/
$ mv node_exporter-0.15.2.linux-amd64 node_exporter
$ vim /etc/systemd/system/node_exporter.service
$ vim /etc/default/node_exporter
$ systemctl daemon-reload
$ systemctl enable node_exporter.service
View index.ios.js
import React, { Component } from 'react'
import {
ART,
AppRegistry,
StyleSheet,
View,
Text,
Dimensions,
Button
} from 'react-native'
View WebViewSample.js
// 外部ブラウザで開く例
import React, { Component } from 'react'
import { Alert, Linking, WebView } from 'react-native'
const ATS_ERROR_CODE = -1022
export default class WebViewSample extends Component {
constructor(props) {
super(props)
View AppDelegate.m
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "AppDelegate.h"
View Client.js
onSubmit(e) {
e.preventDefault()
const fd = new FormData()
fd.append('user[name]', this.state.name)
fd.append('user[email]', this.state.email)
fetch('http://example.com/users', {
method: 'POST',
body: fd
}).then(response =>
response.json()
View AsyncApp.js
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { fetchReposIfNeeded } from '../actions'
import Form from '../components/Form'
import Repos from '../components/Repos'
class AsyncApp extends Component {
constructor(props) {
super(props)
this.handleSubmit = this.handleSubmit.bind(this)
@saitoxu
saitoxu / Frame.js
Last active Apr 5, 2017
2017-04-05
View Frame.js
import React, { Component } from 'react'
export default class Frame extends Component {
componentDidMount() {
const appearin = this.props.appearIn
const roomName = this.props.match.params.roomName
appearin.addRoomToElementById("appearin-frame", roomName)
}
render() {
@saitoxu
saitoxu / App.js
Last active Apr 2, 2017
2017-04-02
View App.js
import React, { Component } from 'react'
import { Link, Route, Switch } from 'react-router-dom'
import Form from './Form'
import Todo from './Todo'
import TodoList from './TodoList'
const Top = () => (
<div>Top</div>
)
@saitoxu
saitoxu / App.js
Last active Mar 30, 2017
2017-03-30
View App.js
import React, { Component } from 'react';
import Form from './Form';
import TodoList from './TodoList';
export default class App extends Component {
constructor() {
super();
this.state = {
todos: []
};
@saitoxu
saitoxu / Board.js
Last active Mar 26, 2017
2017-03-26
View Board.js
import React, { Component } from 'react';
import Square from './Square';
class Board extends Component {
renderSquare(i) {
return <Square key={i}
value={this.props.squares[i].value}
onClick={() => this.props.onClick(i)}
highlighted={this.props.squares[i].highlighted} />;
}