Skip to content

Instantly share code, notes, and snippets.

View kenmori's full-sized avatar

KenjiMorita kenmori

View GitHub Profile
@kenmori
kenmori / file0.txt
Last active August 29, 2015 14:27
脱TS近眼!!Typescriptと仲良くなってみる(1日目) ref: http://qiita.com/M-ISO/items/d4206b506e63da98a1e4
module moritaA{
export interface Imorita {//(1)
get: Function;
num1: number;
num2: number;
}
export class Aclass implements Imorita{
public num1:number = 1
public num2:number = 4
constructor(){
@kenmori
kenmori / file0.txt
Last active August 29, 2015 14:27
TypeScriptでConstructor外で関数を宣言型か無名関数を代入するかでの実行比較 ref: http://qiita.com/M-ISO/items/4401c2ff1c34f4f87156
module A{
interface ImoritaA{
name:string;
}
class Aclass implements ImoritaA{
constructor(public name){
this.name = "fafa"
}
public func1= ()=>{//constructor外、無名関数を代入
}
@kenmori
kenmori / ES6
Last active September 2, 2015 22:58
ES6マラソン・1 〜BabelでES6(Class,let,const,DefaultParameter,Destructuring)がどのようにトランスパイルされるか試して理解する〜 ref: http://qiita.com/M-ISO/items/b3da7913ca0f2140201e
//ex1 babel
function today() { return { d: 6, m: 2, y: 2013 }; }
var { m: month, y: year } = today(); // month = 2, year = 2013
//ex1 after
"use strict";
function today() {
return { d: 6, m: 2, y: 2013 };
}
var _today = today();//関数名が「_変数」になっている
@kenmori
kenmori / file0.js
Last active July 3, 2016 06:31
Angular#serviceと#factoryの違い。どういう時どっちを利用するか。定義方法。使い方を理解するまとめ(2015/8/29更新) ref: http://qiita.com/M-ISO/items/102c6daf192187d5a161
//ex1 //値返す書き方
var myApp = angular.module('MyApp',[]);
myApp.factory('myUrlFactory',function myUrlFunc(){
return 'https://github.com/kenjimorita/';
})
//ex2 //関数を返す書き方
var myApp = angular.module('MyApp',[]);
myApp.factory('myFunc',function($window){
return{
@kenmori
kenmori / immutableJS_Map.js
Last active December 27, 2016 04:29
【Immutable.jsの使い方】Immutable.js超入門~ReactでsetStateのプロパティ値に直接代入避ける~
//mapを作成
var map1 = Immutable.Map({
a: 1,
b:2,
c: 3
});]
//新しい配列やMapを返すところ。不変なオブジェクトを返す
@kenmori
kenmori / 【JavaScript】2以上の配列の差分を新たな配列として返す方法(array-diff) How to return the difference between two sequences as a new array.js
Last active December 27, 2016 04:50
【JavaScript】2以上の配列の差分を新たな配列として返す方法(array-diff) How to return the difference between two sequences as a new array
const arr = [1, 2, 3, 4, 6]
const arr2 = [1, 2, 3, 4, 5]
const arr3 = [...arr, ...arr2]
const a = []
for (let [i, e] of arr3.entries()) {
if(!arr.includes(e)) a.push(e)
if(!arr2.includes(e)) a.push(e)
}
console.log(a)
@kenmori
kenmori / webpack.config.js
Last active December 27, 2016 08:56
【React】これ。SyntaxError: 'import' and 'export' may only appear at the top level
///webpack.config.js変更前/////
module: {
loaders: [
{ test: /\.jsx?$/, exclude: /node_modules/,
loaders: ['react-hot']
}
]
},
///変更後////
@kenmori
kenmori / getElementsByClass[Tag]NameでReact.renderする.js
Last active January 4, 2017 07:51
how to create React element where put on multiple places using the className of div elements instead of an id.
function renderToElements(elements) {
Array.prototype.slice.call(elements).forEach(function(e, i){
React.render(<FavoriteFortune id={e.dataset.id} isFavorite={true} />, e);
})
}
renderToElements(document.getElementsByClassName('favoriteFortune'));
@kenmori
kenmori / json-server-init.json
Created January 5, 2017 06:36
【DHC/JsonServer使い方】APIテストに便利!「JSONserver」をlocalに立ててAPIを返しローカルエディタや「DHC REST Client」でPOSTやGETリクエストするためのexample
{
"comments": [
{
"body": "some comment",
"id": 1,
"postId": 1
}
],
"posts": [
{
@kenmori
kenmori / 接続認証エラーが発生しました。理由: ユーザーIDまたはパスワードが無効です.xml
Created January 7, 2017 00:42
Error in allocating a connection. Cause: Connection could not be allocated because:接続認証エラーが発生しました。理由: ユーザーIDまたはパスワードが無効です
<properties>
<property name="eclipselink.jdbc.user" value="APP"/>
<property name="eclipselink.jdbc.password" value="APP"/>
</properties>