Skip to content

Instantly share code, notes, and snippets.

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

Kay Gosho acro5piano

🏠
Working from home
View GitHub Profile
'use strict';
const fs = require('fs');
const assert = require('assert').strict;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
@acro5piano
acro5piano / file0.txt
Last active December 20, 2018 09:23
TypeScript の型定義から GraphQL のクエリを出力するライブラリを作った ref: https://qiita.com/acro5piano/items/602c4c042f01070204a7
interface GetUserQueryData {
getUser: {
id: number
name: string
bankAccount: {
id: number
branch: string
}
}
}
@acro5piano
acro5piano / file0.txt
Last active December 3, 2018 01:31
jsx-no-lambda を recompose で回避 ref: https://qiita.com/acro5piano/items/7c90255a449295a43e59
// NG
const Component = ({ onChange }) => (
<input onChange={e => onChange(e.target.value)} />
)
export default Component
@acro5piano
acro5piano / file0.txt
Last active November 27, 2018 09:06
pip install nkf できない時の対処法 ref: https://qiita.com/acro5piano/items/64c91bd67fe8c3ca559b
(venv) [ec2-user@ip-172-55-55-55 tmp.szI1BtAgOR]$ pip install nkf
Collecting nkf
Cache entry deserialization failed, entry ignored
Could not find a version that satisfies the requirement nkf (from versions: )
No matching distribution found for nkf
@acro5piano
acro5piano / App.tsx
Created October 27, 2018 05:56
fetch data HOC with strongly typed
import * as React from 'react'
import { get, WithData } from './decorator'
import * as moment from 'moment'
interface PostResponse {
id: number
userId: number
title: string
body: string
}
@acro5piano
acro5piano / file0.txt
Last active October 24, 2018 00:35
TypeScript で、入力に応じて特定の型を返す Overload Signature の使い方 ref: https://qiita.com/acro5piano/items/208a96997d1beab5ad38
export function invert(n: number | string): string | number {
return typeof n === 'string' ? parseInt(n) : String(n)
}
@acro5piano
acro5piano / emailify.tsx
Last active October 23, 2018 07:08
React Component -> Email template
import * as React from 'react'
import { renderToString } from 'react-dom/server'
import { ServerStyleSheet } from 'styled-components'
import juice from 'juice'
interface HtmlTemplateProps {
body: string
styles: string
title: string
}
#!/bin/bash
cat db/schema.rb \
| grep -v add_foreign_key \
| grep -v t.index \
| grep -v 'end$' \
| grep -v 'ActiveRecord::Schema.define' \
| grep -v '^#' \
| grep -v 'These are extensions that must' \
| grep -v 'plpgsql' \
@acro5piano
acro5piano / Cartfile
Last active October 23, 2018 10:42
React Native Firebase が Carthage を認識してくれない ref: https://qiita.com/acro5piano/items/694ff0189b3701f7a62d
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json"
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAuthBinary.json"
@acro5piano
acro5piano / file0.php
Last active October 9, 2019 16:52
Laravel で GraphQL やるなら、 Lighthouse が良い ref: https://qiita.com/acro5piano/items/b9e3acd4af5ec14d7bb1
class UserType extends GraphQLType
{
protected $attributes = [
'name' => 'User',
'description' => 'A user'
];
public function fields()
{
return [