Skip to content

Instantly share code, notes, and snippets.

onionmk2

Block or report user

Report or block onionmk2

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View propTypes_oneOfType.js
import React from 'react'
import NavLink from './NavLink'
import Repo from './Repo'
export default React.createClass({
propTypes: {
children: React.PropTypes.oneOfType([
React.PropTypes.arrayOf(React.PropTypes.instanceOf(Repo)),
React.PropTypes.instanceOf(Repo)
])
@onionmk2
onionmk2 / react_tutorial_client.jsx
Created Sep 14, 2016
react_tutorial_client.jsx
View react_tutorial_client.jsx
const DOMPurify = require('dompurify');
const React = require('react');
const ReactDOM = require('react-dom');
const Remarkable = require('remarkable');
const Comment = React.createClass({
propTypes: {
author: React.PropTypes.string.isRequired,
children: React.PropTypes.string.isRequired,
},
@onionmk2
onionmk2 / react_tutorial_server.js
Created Sep 14, 2016
react_tutorial_server.js
View react_tutorial_server.js
const Http = require('http');
const Url = require('url');
const Path = require('path');
const Fs = require('fs');
const COMMENTS_FILE = 'comments.json';
const server = Http.createServer(function requestListener(inComingMessage, serverResponse) {
console.log(inComingMessage.method, inComingMessage.url, `at ${new Date()}`);
console.log(inComingMessage.headers);
View spacer.scss
@function str-replace($string, $search, $replace: '') {
$index: str-index($string, $search);
@if $index {
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
}
@return $string;
}
@onionmk2
onionmk2 / trip.ts
Created Nov 19, 2016
分岐を多態で置き換える
View trip.ts
class Trip {
destination: string;
startDate: Date;
constructor(destination, startDate) {
this.destination = destination;
this.startDate = startDate;
}
prepare(preparers) {
@onionmk2
onionmk2 / memo.md
Last active Dec 10, 2016
typescript環境の備忘録
View memo.md
@onionmk2
onionmk2 / tsconfig.json
Created Nov 30, 2016
reactでの tsconfig.json 一例
View tsconfig.json
{
"compilerOptions": {
"outDir": "./dist/",
"module": "commonjs",
"target": "es5",
"noImplicitAny": true,
"inlineSourceMap": true,
"experimentalDecorators": true,
"jsx": "react",
"pretty": true,
@onionmk2
onionmk2 / gist:895879d0a6a2fe2b6ec28b636fc809cc
Last active Dec 6, 2016
prototypeにはえてるプロパティをenumrableなものも取りたいときの方法
View gist:895879d0a6a2fe2b6ec28b636fc809cc
let fs = require('fs');
function log(targat) {
const target = targat.prototype;
const fileName = __dirname + '/dist/' + target.constructor.name + '.txt';
const props = Object.getOwnPropertyDescriptors(target);
const str = Object.keys(props).join('\n');
fs.createWriteStream(fileName).write(str);
}
@onionmk2
onionmk2 / functionType.ts
Last active Dec 4, 2016
TypeScriptの関数の型
View functionType.ts
/*
#1 関数宣言
function funcName() : returnType => {}
*/
function funcName (x) {}
function funcNameTs(x: number): number { return x;}
/*
#2 関数式
*/
View interface.ts
/*
TSのインターフェースとは 以下2つのうちのいずれか。
1. 抽象的な型。 プロパティの名前・型を指定した、JSオブジェクト。
2. 引数と戻り値の型を明示した、Functionオブジェクト。
http://stackoverflow.com/questions/41082804/does-typescript-interface-have-anonymous-and-named-function/41082880#41082880
*/
// 1. JSオブジェクト
You can’t perform that action at this time.