Skip to content

Instantly share code, notes, and snippets.

import CryptoJS from 'crypto-js';
import {v4 as uuidv4 } from "uuid"
// https://github.com/paypay/paypayopa-sdk-node/blob/646a420f6e61f65cfd4855f355d21de95af5fef8/src/lib/paypay-rest-sdk.ts#L31
// ↑ここから引っ張ってきてとりあえず動くっぽい感じにしたやつ
export const createAuthHeader = (method: string, resourceUrl: string, payLoad: any, auth: any) => {
let AUTH_TYPE = "hmac OPA-Auth";
const epoch = Math.ceil(Date.now() / 1000); // ミリ秒を削る必要アリ
let contentType = 'application/json';
const nonce = uuidv4().slice(0,8);
overwrite: true
schema: https://XXXXXXX.herokuapp.com/v1/graphql
documents:
- query.graphql
generates:
src/generated/types.d.ts:
plugins:
- "typescript"
# - "typescript-document-nodes"
# - "typescript-operations"
let pow: Vec<&i32> = v1
.iter()
.enumerate()
.filter_map(|(i, v)| v2.get(i))
.collect();
let pow2: Vec<i32> = v1
.iter()
.enumerate()
.filter_map(|(i, v)| v2.get(i))
.map(|d| d.clone())
@terrierscript
terrierscript / hooks.js
Created February 10, 2019 23:36
react-hooks-google-map-4-B
import { useEffect, useState, useCallback, useReducer, useRef } from "react";
import GoogleMapsApiLoader from "google-maps-api-loader";
// @ts-ignore
import uuid from "uuid/v4";
// Google Mapのオブジェクトを呼び出すだけのhooks
export const useGoogleMap = apiKey => {
const [googleMap, setGoogleMap] = useState(null);
useEffect(() => {
GoogleMapsApiLoader({ apiKey }).then(google => {
@terrierscript
terrierscript / hooks.js
Last active February 10, 2019 23:41
react-hooks-google-map-part4-A
import { useEffect, useState, useCallback, useReducer, useRef } from "react";
import GoogleMapsApiLoader from "google-maps-api-loader";
// @ts-ignore
import uuid from "uuid/v4";
// Google Mapのオブジェクトを呼び出すだけのhooks
export const useGoogleMap = apiKey => {
const [googleMap, setGoogleMap] = useState(null);
useEffect(() => {
GoogleMapsApiLoader({ apiKey }).then(google => {
@terrierscript
terrierscript / hooks.js
Last active April 6, 2024 07:58
react-hooks-google-map-part3
import { useEffect, useState, useCallback, useRef } from "react";
import GoogleMapsApiLoader from "google-maps-api-loader";
// Google Mapのオブジェクトを呼び出すだけのhooks
export const useGoogleMap = apiKey => {
const [googleMap, setGoogleMap] = useState(null);
useEffect(() => {
GoogleMapsApiLoader({ apiKey }).then(google => {
setGoogleMap(google);
});
import React, { createContext, Context, useContext } from "react"
interface SafetyContextValue extends Object {
isDefault: boolean
}
export const createSafetyContext = <T extends SafetyContextValue>(
defaultValue: T
) => {
return createContext({
// https://github.com/terrierscript/dartystrap/blob/2b5c0a2fc7bb0060b2290664384303bab802d94f/src/app/compiler/CompileModeCheckbox.tsx#L21-L37
const useCompileModeCheckboxState = () => {
const [compilerMode, setCompilerMode] = useState(CompilerMode.WORKER)
const handleUseWorker = useCallback(
(e) => {
const mode = e.target.checked ? CompilerMode.WORKER : CompilerMode.ASYNC
setCompilerMode(mode)
},
[setCompilerMode]
@terrierscript
terrierscript / file0.txt
Last active October 17, 2018 09:23
redux-observableで複数のActionを発火する方法をたくさん考える ref: https://qiita.com/terrierscript/items/0feecfcb61144e68d7ac
const Button = ({ dispatch }) => (
<button onClick={(e) => dispatch({ type: "PING" })}>
Ping
</button>
)
const readline = require("readline")
const seeds = [
// 使いたい漢字を列挙する
]
const firstName = "" // 名字
const getRandomInt = (len) => {
return Math.ceil(Math.random() * len)
}
const pick = (arr) => {