Skip to content

Instantly share code, notes, and snippets.

View tai2's full-sized avatar
🐢

Taiju Muto tai2

🐢
View GitHub Profile
@tai2
tai2 / utilities.bash
Last active April 2, 2022 03:08
Shell utilities
function zcd() {
cd $(z | tail -r | fzf --layout=reverse --cycle | awk "{print \$2}")
}
function ge() {
FILE=`git grep "$@" | fzf --layout=reverse --cycle | cut -d : -f 1`
nvr --remote $FILE
}
function gt() {
@tai2
tai2 / rails-sidekiq-concurrency.md
Last active March 23, 2022 06:51
Rails/Sidekiqアプリにおけるconcurrency, connection poolまわりの設定条件

Rails/Sidekiqアプリにおけるconcurrency, connection poolまわりの設定条件

rails redis concurrency

https://whimsical.co/SJK9Qzo733f6jkw1Tfk4dT

仮定

  • サーバーインスタンス(dyno)、ワーカーインスタンス(dyno)はそれぞれ1つずつ
  • Sidekiqジョブは毎回DB接続を要求する
@tai2
tai2 / jquery-selectmenu.js
Last active September 11, 2021 11:30
jquery ui select menu vue component
Vue.component('jquery-selectmenu', {
props: ['value'],
template: `<select><slot /></select>`,
mounted: function() {
const emit = value => this.$emit('input', value);
$(this.$el).selectmenu({
change: function(event, data) {
emit(data.item.value);
}
});

特に重要なのは、先に数字を言った方が確実に不利になることだ。どのような交渉でも、自分の条件はあとから言うようにしたい。理由はこうだ。たとえば、ある募集に応募して、そのポストの給与は7万ドルだと見込んでいたとする。採用が内定して最初に尋ねられるのは、給与としていくら必要かだ。そこであなたは7万ドルくらいのポストを探していると答える。もっと賢く、7万ドルから8万ドルの範囲で、と言うかもしれない。採用担当マネージャーは、すぐに7万5千ドルではどうかと言ってくるだろう。あなたは首を縦に振り、契約を受け入れ、めでたしめでたしとなる。ただ、この話には大きな問題がひとつあった。その採用担当マネージャーは、8万ドルから10万ドルの予算を立てていたのである。あなたが先に数字を口に出したので、年に2万5千ドルも自分を割り引いてしまったのだ。これは極端な例だと思われるかもしれないが、そんなことはない。他人がどのような額を提示するかは、相手があなたに言うまでわからない。先に自分の数字を言ってしまうと、あなたは確実に不利になる。あなたは自分が言った額より上を要求するわけにはいかなくなるが、交渉でその額よりも引き下げられてしまう可能性はある。先に数字を言ってしまうと、上はなくなり、大きく引き下げられる危険だけが残る。

ジョン・ソンメズ. SOFT SKILLS ソフトウェア開発者の人生マニュアル (Japanese Edition) (Kindle Locations 5399-5408). Kindle Edition.

@tai2
tai2 / elgamal.py
Created April 3, 2020 14:32
エルガマル暗号?
#-*- coding: utf-8 -*-
"""
エル・ガマル公開鍵暗号系の仕組みを理解するために素朴に実装してみる。も
とのメッセージは、バイト列として受け取り、整数のリストに暗号化する。
エルガマル暗号系は、g^k ≡ a(mod p)の形の合同式において、p,g,kからaを
計算するのは簡単だが、逆にp,gaから、kを決定するのは難しいこと(離散対数
問題)を利用した、公開鍵暗号系である。
@tai2
tai2 / rsa.py
Created April 3, 2020 14:32
RSA実装?
#-*- coding: utf-8 -*-
"""
RSA公開暗号方式の仕組みを理解するために素朴に実装してみる。もとのメッ
セージは、バイト列として受け取り、整数のリストに暗号化する。
RSAは、(大きな数になると)素数の積を計算するのは簡単だが、逆に、合成数
を素因数分解するのは難しいという事実を利用したアルゴリズムである。
@tai2
tai2 / codereview.md
Created February 19, 2020 05:32
How to do a code review 個人的まとめ
@tai2
tai2 / README.md
Created December 11, 2019 04:08
OpenAPI go-gin-server

Go API Server for openapi

This is a sample server Petstore server. For this sample, you can use the api key special-key to test the authorization filters.

Overview

This server was generated by the [openapi-generator] (https://openapi-generator.tech) project. By using the OpenAPI-Spec from a remote server, you can easily generate a server stub.

@tai2
tai2 / README.md
Created December 11, 2019 04:02
OpenAPI go-server

Go API Server for openapi

This is a sample server Petstore server. For this sample, you can use the api key special-key to test the authorization filters.

Overview

This server was generated by the [openapi-generator] (https://openapi-generator.tech) project. By using the OpenAPI-Spec from a remote server, you can easily generate a server stub.