Skip to content

Instantly share code, notes, and snippets.

View kenmori's full-sized avatar
🏠
Working from home

KenjiMorita kenmori

🏠
Working from home
View GitHub Profile
@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>
@kenmori
kenmori / UserEntity.java
Created January 7, 2017 11:45
【glassFish】これが出たら疑う箇所Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.EntityManagerSetupException
@Entity
@SecondaryTables({
@SecondaryTable(name = "zipcode_tbl"),//not much!!
@SecondaryTable(name = "address_tbl"),
})
@Table(name="user_data_2")
public class UserEntity02 implements Serializable {
@Id @NotNull
private String id;
private String name;
@kenmori
kenmori / persistence.xml
Created January 7, 2017 12:30
【JavaDB/glassFish】解決!Internal Exception: java.sql.SQLSyntaxErrorException: 表またはビュー'[TABLE_NAME]'は存在しません。
<properties>
<!--add this code, if you use eclipselink -->
<property name="eclipselink.ddl-generation" value="create-tables"/>
@kenmori
kenmori / uninstall.sh
Created January 8, 2017 00:57
【Rust/rustup/multirust】uninstallしたい!「rustup cannot be installed alongside [Rust|multirust]. Please uninstall first」rustcが邪魔してrustupがinstallできない場合1つの方法
sudo /usr/local/lib/rustlib/uninstall.sh
@kenmori
kenmori / example.js
Last active August 5, 2017 05:45
【Reactのstateとpropsの違いが知りたい!(変更・更新の仕方等デモあり)】過去のReact初心者の自分にpropsとstateの違いを説明する
class ParentComponent extends React.Component {
constructor(props){
super(props)
this.state = {
name: "わたし"
};
this.onChangeName = this.onChangeName.bind(this);
}
onChangeName(){
const name = this.state.name === "あなた" ? "わたし" : "あなた";
@kenmori
kenmori / index.md
Created February 5, 2017 02:07
イベントデリゲーション

問321

イベントデリゲーションに関して。 こちらのDOMの

<ul id="todo-app">
  <li class="item">Walk the dog</li>
  <li class="item">Pay bills</li>
  <li class="item">Make dinner</li>