Skip to content

Instantly share code, notes, and snippets.

View FujiHaruka's full-sized avatar
💭
Just because

Fuji Haruka FujiHaruka

💭
Just because
View GitHub Profile
@FujiHaruka
FujiHaruka / App.tsx
Created April 11, 2018 15:18
Example to use "recompose" module in TypeScript
import * as React from 'react'
import { withStateHandlers, StateHandler, StateHandlerMap, StateUpdaters } from 'recompose'
type OuterProps = {}
interface AppState {
userName: string
}
interface AppStateHanlderMap extends StateHandlerMap<AppState> {
@FujiHaruka
FujiHaruka / translation_badge.md
Last active May 16, 2019 07:42
ドキュメントの翻訳が最新コミットに追従しているかをチェックするバッジ

ドキュメントの翻訳が最新コミットに追従しているかをチェックするバッジ

英語のドキュメントを翻訳していると、翻訳が古くなることがある。本家ドキュメントが GitHub で管理されていれば、本家が更新されて翻訳が古くなったときに、差分だけを翻訳し直して最新に追従するといったことができる。そうするためには、翻訳ドキュメントの中に本家ドキュメントのコミットハッシュ値を書き残しておけばよい。本家が更新されたら、最新のコミットと、翻訳が参照しているコミットを見比べる。

このやり方を応用して、翻訳ドキュメントが本家の最新コミットに追従しているかどうかをひと目でわかるようにしたのが、このバッジである。

translation badges

バッジには本家ドキュメントのコミットハッシュ値が含まれていて、その値が本家の最新のコミットハッシュ値を一致していれば up to date と表示され、一致していなければ out of date と表示される。

@FujiHaruka
FujiHaruka / mongoose-model-type.ts
Created February 8, 2020 02:53
How to get Model type from Schema definition object using generic type in mongoose
import { Schema, model, Document } from 'mongoose'
// ----------------------------
// Definition of Modeled<T>
// ----------------------------
// Object that has "type" property
type TypeObjectEnd = { type: any }
// Nested object that has TypeObjectPrimitive recursively
@FujiHaruka
FujiHaruka / chromy-instagram.js
Created September 2, 2017 06:36
Headless chrome example to search instagram
const Chromy = require('chromy')
const hashtag = 'しまむら'
const chromy = new Chromy()
chromy.chain()
.goto(`https://www.instagram.com/explore/tags/${hashtag}/`)
.wait('img') // wait to render
.evaluate(() => {
const images = document.querySelectorAll('img')
@FujiHaruka
FujiHaruka / global-overwritten-detector.js
Created April 21, 2022 01:54
Detect JS native functions overwritten or added by such as polyfills
(() => {
const isFuncProperty = (obj, key) => {
if (key === "constructor" || key === "prototype") {
// except constructor
return false;
}
let is = false;
try {
is = typeof obj[key] === "function";
} catch (e) {
@FujiHaruka
FujiHaruka / latest_commit_hash_of_file.graphql
Created May 11, 2019 10:57
GraphQL query to get latest commit hash of a file
{
repository(name: "TypeScript", owner: "Microsoft") {
ref(qualifiedName: "master") {
target {
... on Commit {
history(first: 1, path: "tslint.json") {
edges {
node {
oid
}