Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

KenjiMorita kenmori

🏠
Working from home
View GitHub Profile
@kenmori
kenmori / file0.txt
Last active Aug 29, 2015
脱TS近眼!!Typescriptと仲良くなってみる(1日目) ref: http://qiita.com/M-ISO/items/d4206b506e63da98a1e4
View file0.txt
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 Aug 29, 2015
TypeScriptでConstructor外で関数を宣言型か無名関数を代入するかでの実行比較 ref: http://qiita.com/M-ISO/items/4401c2ff1c34f4f87156
View file0.txt
module A{
interface ImoritaA{
name:string;
}
class Aclass implements ImoritaA{
constructor(public name){
this.name = "fafa"
}
public func1= ()=>{//constructor外、無名関数を代入
}
@kenmori
kenmori / ES6
Last active Sep 2, 2015
ES6マラソン・1 〜BabelでES6(Class,let,const,DefaultParameter,Destructuring)がどのようにトランスパイルされるか試して理解する〜 ref: http://qiita.com/M-ISO/items/b3da7913ca0f2140201e
View ES6
//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 Jul 3, 2016
Angular#serviceと#factoryの違い。どういう時どっちを利用するか。定義方法。使い方を理解するまとめ(2015/8/29更新) ref: http://qiita.com/M-ISO/items/102c6daf192187d5a161
View file0.js
//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 Dec 27, 2016
【Immutable.jsの使い方】Immutable.js超入門~ReactでsetStateのプロパティ値に直接代入避ける~
View immutableJS_Map.js
//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 Dec 27, 2016
【JavaScript】2以上の配列の差分を新たな配列として返す方法(array-diff) How to return the difference between two sequences as a new array
View 【JavaScript】2以上の配列の差分を新たな配列として返す方法(array-diff) How to return the difference between two sequences as a new array.js
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 Dec 27, 2016
【React】これ。SyntaxError: 'import' and 'export' may only appear at the top level
View webpack.config.js
///webpack.config.js変更前/////
module: {
loaders: [
{ test: /\.jsx?$/, exclude: /node_modules/,
loaders: ['react-hot']
}
]
},
///変更後////
@kenmori
kenmori / getElementsByClass[Tag]NameでReact.renderする.js
Last active Jan 4, 2017
how to create React element where put on multiple places using the className of div elements instead of an id.
View getElementsByClass[Tag]NameでReact.renderする.js
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 Jan 5, 2017
【DHC/JsonServer使い方】APIテストに便利!「JSONserver」をlocalに立ててAPIを返しローカルエディタや「DHC REST Client」でPOSTやGETリクエストするためのexample
View json-server-init.json
{
"comments": [
{
"body": "some comment",
"id": 1,
"postId": 1
}
],
"posts": [
{
@kenmori
kenmori / 接続認証エラーが発生しました。理由: ユーザーIDまたはパスワードが無効です.xml
Created Jan 7, 2017
Error in allocating a connection. Cause: Connection could not be allocated because:接続認証エラーが発生しました。理由: ユーザーIDまたはパスワードが無効です
View 接続認証エラーが発生しました。理由: ユーザーIDまたはパスワードが無効です.xml
<properties>
<property name="eclipselink.jdbc.user" value="APP"/>
<property name="eclipselink.jdbc.password" value="APP"/>
</properties>