Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

KenjiMorita kenmori

🏠
Working from home
View GitHub Profile
View jest-example.md

jest

import { add, addString, toNumber, filterOrange } from "./index";

it('adds 1 + 2 to equal 3', () => {
  expect(add(1, 2)).toBe(3);
});
View gist:7b96d6336e3069a19141db0c415a29e5
"use strict";

const modal = document.getElementById("js-modal");
const modalWrapper = document.getElementById("js-modalWrapper");
const checkbox = document.getElementById("js-checkbox");
const closeButton = document.getElementById("js-close");

const form = document.getElementById("js-form");
const term = document.getElementById("js-term");
View Win-nvm.md

ref

Windows 10 Fall Creators Update - Installing Node.js on Windows Subsystem for Linux (WSL)

Windows just released the windows subsystem for linux feature to the public with its latest windows fall creator update, if you are not familiar with this feature it allows you to run linux binaries natively on windows - F.A.Q.

Enabling WSL

The feature is not enabled by default and you need to activate it, you can do it via powershell (with admin rights):

View Win-nvm-md
[ref](https://gist.github.com/noygal/6b7b1796a92d70e24e35f94b53722219)
# Windows 10 Fall Creators Update - Installing Node.js on Windows Subsystem for Linux (WSL)
Windows just released the [windows subsystem for linux](https://msdn.microsoft.com/en-us/commandline/wsl/about) feature to the public with its latest windows fall creator update, if you are not familiar with this feature it allows you to run linux binaries natively on windows - [F.A.Q](https://msdn.microsoft.com/en-us/commandline/wsl/faq).
## Enabling WSL
The feature is not enabled by default and you need to activate it, you can do it via powershell (with admin rights):
View typescript108.md
View example.js
class Store {
status = ""
cycleCount = 0;
count = 0;
constructor(status){
this.status = status
this.cycleCount = 3;
this.count = 1;
}
@kenmori
kenmori / rust_practice.md
Last active Mar 24, 2021
【WIP】Rust練習問題集(Rust practice questions)
View rust_practice.md

【WIP】Rust練習問題集(Rust practice questions)

Author

読み進めるにあたって

- 問題文はfn main{}の中のコンテキストとする
@kenmori
kenmori / React Hooks-modules-for-reload-and-tab close which react-router prompt cannot support.md
Last active Apr 18, 2020
【React Hooks】modules for reload and tab close which react-router prompt cannot support
View React Hooks-modules-for-reload-and-tab close which react-router prompt cannot support.md

【React Hooks】 modules for reload and tab close which react-router prompt cannot support

react-routerのPromptではreloadとtabクローズに対応できなさそうなので作った

isDuty ・・・A flag that determines if the user has edited the value of the form. got from formik etc.

// in /modules/useUnloadEffect
@kenmori
kenmori / 【簡単!!】swaggerモックサーバーをローカルに立ち上げて、データ作って叩きたい.md
Created Apr 4, 2020
【簡単!!】swaggerモックサーバーをローカルに立ち上げて、データ作って叩きたい
View 【簡単!!】swaggerモックサーバーをローカルに立ち上げて、データ作って叩きたい.md
global.fetch = require("node-fetch")

async function getApi(id){
  try {
  const response = await fetch(`https://petstore.swagger.io/v2/pet/${id}`, {
    method: "GET",
    mode: "cors",
    credentials: "include",
    headers: {
@kenmori
kenmori / exif.md
Last active Mar 27, 2020
【解決】[Solution] Support for tilting 90 degrees when uploading an iPhone image file(iPhoneの画像ファイル(File)をアップロードすると横向きに(90度回転)傾く対応)
View exif.md

【解決】iPhoneの画像ファイル(File)をアップロードすると横向きに(90度回転)傾く対応)

Upload the iPhone image file (File) to tilt horizontally (rotate 90 degrees) ~ iPhoneの画像ファイル(File)をアップロードした際に90度傾く対応) ~

フロントエンドでEXIFという画像のメタデータ内のOrientationの値を考慮して処理しないとそうなる。

よくある記事はimageのnodeに突っ込んでプレビューに出すみたいなのは多いのだけれど、 そうではなく、File型としてセットしたい時の方法。 callback関数を渡して、そこに処理させる