Skip to content

Instantly share code, notes, and snippets.

View tkdn's full-sized avatar
🏠
Working From Home.

Satoshi Takeda tkdn

🏠
Working From Home.
View GitHub Profile
@tkdn
tkdn / pluck.ts
Created November 9, 2018 02:37
like `array_pluck` on Laravel
const pluck = (
array: Array<{[key: any]: value: any}>,
props: string[],
pickedKey: string,
): {[valuePickedByKey: any]: {[prop:any]: any}} => {
return array.reduce((prevOut, item) => {
const valuePickedByKey = item[pickedKey];
const pickedObj = props.reduce((prevItem, pickProp) => {
return {
...prevItem,
@tkdn
tkdn / summary.md
Created August 30, 2018 04:23
GraphQL について知っておきべく事

以下、記事の要約と個人的な疑問点などです。 GraphQL: Everything You Need to Know – Weblab Technology – Medium

また記事中に出てくるサンプルについてはより削ぎ落としたもので、依存がほとんどない。 GraphQL はクライアントからすると、クライアントキャッシングやその他課題はあるものの、クエリ言語である以外何者でもなさそうというがよく分かる。


@tkdn
tkdn / index.test.tsx
Created August 13, 2018 08:34
Next.js' `nextjs-dynamic-routes` unit-test
import { Index } from '@Components/pages'
import * as React from 'react'
import { cleanup, render } from 'react-testing-library'
jest.mock('../../../routes', () => {
const React = require('react')
return {
Link: ({ children }) => {
return <div>{children}</div>
}
@tkdn
tkdn / Brewfile
Last active August 28, 2019 09:49
tap "fujiwara/tap"
tap "getsentry/tools"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-versions"
tap "homebrew/core"
tap "libero18/mycask"
tap "olleolleolle/adr-tools"
tap "rcmdnk/file"
tap "stns/stns_passwd"
@tkdn
tkdn / Brewfile
Last active April 9, 2021 19:25
ReMac
tap "fujiwara/tap"
tap "getsentry/tools"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-versions"
tap "homebrew/core"
tap "homebrew/services"
tap "libero18/mycask"
tap "olleolleolle/adr-tools"
tap "rcmdnk/file"
@tkdn
tkdn / foo.jsx
Created June 16, 2017 14:28 — forked from tmeasday/foo.jsx
Redux container
// This is a vastly simplified implementation of what a Redux container would do
class MyComponentContainer extends Component {
mapStateToProps(state) {
// this function is specific to this particular container
return state.foo.bar;
}
render() {
// This is how you get the current state from Redux,
// and would be identical, no mater what mapStateToProps does
export function prevLocation(state = {
refDomNode: null,
method: null
}, action) {
switch (action.type) {
case LOCATION_CHANGE:
const method = action.payload.action
return Object.assign({},state,{
method: method
})
@tkdn
tkdn / file0.js
Last active August 29, 2015 14:16
jQuery その先のUIアニメーション ref: http://qiita.com/tkdn/items/fc8425605bdbcfc3f893
$(function() {
var action = (function(jqObject) {
var content = jqObject.next('.content');
var contentParent = content.parent();
if(contentParent.hasClass('active')){
content.slideUp('250',function(){
contentParent.removeClass('active');
});
} else {
contentParent.addClass('active');
@tkdn
tkdn / index.js
Last active August 29, 2015 14:15
browserify - jqueryの$をスコープの中に閉じ込めたほうがよいのか、他1点 ref: http://qiita.com/tkdn/items/a29db5b0f30e28018952
var $ = require('jquery');
require('jquery.plugin01');
require('jquery.plugin02');
@tkdn
tkdn / custom-helper.js
Created February 14, 2015 05:02
Assemble - Handlebars.js でヘルパーからオブジェクトを参照する ref: http://qiita.com/tkdn/items/499d253c0c71ebdaf56b
module.exports.register = function (Handlebars, options, params) {
'use strict';
Handlebars.registerHelper('foo', function(str) {
return str;
});
};