Skip to content

Instantly share code, notes, and snippets.

View hypermkt's full-sized avatar

Makoto Chiba hypermkt

View GitHub Profile
@hypermkt
hypermkt / git-delete-select-branch
Created August 2, 2020 15:19
Delete selected multi branch
#/bin/bash
# from SO: https://stackoverflow.com/a/54261882/317605 (by https://stackoverflow.com/users/8207842/dols3m)
function prompt_for_multiselect {
# little helpers for terminal print control and key input
ESC=$( printf "\033")
cursor_blink_on() { printf "$ESC[?25h"; }
cursor_blink_off() { printf "$ESC[?25l"; }
cursor_to() { printf "$ESC[$1;${2:-1}H"; }
print_inactive() { printf "$2 $1 "; }
$ loan-simulator -y 35 -i 1 -a 3000
返済期間: 35 年
返済期間: 420 ヶ月
金利: 1 %
月利: 0.0008333333333333334
借入金額: 3000 万円
借入金額: 30000000 円
---
+------+---------+--------+-------+-------+----------+

リソースの複数削除

実装方法

パターン1: DELETEメソッドで対象IDを複数個指定

DELETE /resources?ids=recordId1,recordId2

Request

無し

Response

204 No Content

@hypermkt
hypermkt / web-api-the-good-parts-reading-memo.md
Last active February 21, 2018 05:39
Web API The Good Partsの読書メモ

Web API The Good Parts 読書メモ

5章 設計変更をしやすいWeb APIを作る

  • APIをバージョン管理する
    • URIのバージョンを埋め込む
      • URIのパスの一番先頭につけるのが一般的
      • v を先頭につけることでバージョンとはっきり分かる
    • バージョンをクエリ文字列に入れる
      • パスとクエリ文字列の違いは、それが省略可能であること
  • デフォルトでは最新バージョンか下位バージョンはサービス次第
@hypermkt
hypermkt / マイクロサービスアーキテクチャ.md
Last active September 16, 2020 04:46
マイクロサービスアーキテクチャの読書メモです

マイクロサービスアーキテクチャ 読書メモ

1章 マイクロサービス

  • マイクロサービスは、協調して動作する小規模で自律的なサービスである
    • 小さく、かつ1つの役割に専念する
    • 独立したシステムで、サービス間はAPIで通信をする
  • メリット
    • サービス毎に異なる技術を使用できる、迅速に技術を採用できる
      • 但し複数の技術の採用はオーバーヘッドが伴う
  • システムのあるコンポーネントに障害が発生しても、その障害が連鎖しなければ、問題を分離してシステムの残りの部分は機能し続けることができる
<?php
$base_url = 'xxx';
$data = [
"text" => "Would you like to play a game?",
"attachments" => [
[
"text" => "Choose a game to play",
"fallback" => "You are unable to choose a game",
@hypermkt
hypermkt / vuejs_testing_research.md
Last active June 20, 2017 10:31
Vue.js Testing 調査

Vue.js Testingに関する調査

背景

Testingライブラリ

  • ライブラリはいくつかあったが、どれもオフィシャルではない。
  • 2017年6月1日にVue.js本件のOrganizationで vue-test-utilsが誕生している
/var/tmp/php-build/source/5.6.0/ext/opcache/ZendAccelerator.c:397:28: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        CG(interned_empty_string) = accel_new_interned_string("", sizeof(""), 0 TSRMLS_CC);
                                  ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: ext/opcache/.libs/opcache.a(shared_alloc_shm.o) has no symbols
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: ext/opcache/.libs/opcache.a(shared_alloc_shm.o) has no symbols
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: /var/tmp/php-build/source/5.6.0/modules/opcache.a(shared_alloc_shm.o) has no symbols
/var/tmp/php-build/source/5.6.0/ext/date/php_date.c:2245:6: warning: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value]
               

非同期バリデーション

非同期のバリデーションを使用することができます。これはサーバーサイドバリデーションのように使用するときに便利です。下記は例です:

<template>
  <validator name="validation">
    <form novalidate>
      <h1>user registration</h1>
      <div class="username">

バリデーションタイミング変更

vue-validator は validator エレメントディレクティブと v-validate ディレクティブで自動的にバリデートを実行します。しかしながら時々、自動バリデーションを無効化し手動でバリデートを実行したい時があります。

initial

vue-validator は初回コンパイルを終えると、それぞれの v-validate ディレクティブは自動的に対象エレメントのバリデートを実行します。もしこの挙動を望まない場合は、 initial 属性又は v-validate を指定できます:

<div id="app">
  <validator name="validation1">