要旨 const args = process.argv.slice(2, process.argv.length) console.log(args) 出力 $ node index.js abcde [ 'abcde' ] 詳細 process.argv[0] には node ヘのpathが、 process.argv[1] には ファイルへのpathが入っている。これを確かめたのが以下のス…
要旨 import { interval } from 'rxjs'; const observable = interval(1000); const subscription = observable. subscribe(i => console.log(i)); setTimeout(() => subscription.unsubscribe(), 3000); 出力 /app # node tmp.js 0 1 /app # 参考 rxjs.dev
要旨 class MyClass { publicMethod() { return 'publicMethod' } #privateMethod() { return 'privateMethod' } } mc = new MyClass() console.log(mc.publicMethod()) console.log(mc.privateMethod()) 実行結果 > class MyClass { ... publicMethod() { .…
要旨 VALUE="true" if [ "x${VALUE:-false}" = "xtrue" ]; then echo "trueが入っている" else echo "falseが入っている" fi 詳細 ${VALUE:-false} これはデフォルト値を定めている。もし VALUE が未定義なら、 - の後ろに書いた値が使用される。 参考 tldp.…
要旨 console.log('lv. 0') console.group() console.log('lv. 1') console.groupEnd() console.group() console.group() console.log('lv. 2') console.groupEnd() console.log('lv. 1') console.groupEnd() console.log('lv. 0') console.group() を使った…
要旨 git push origin `git rev-parse --abbrev-ref HEAD` 詳細 git rev-parse --abbrev-ref HEADは、現在居るブランチの名前を返してくれる。下記がその例。 $ git rev-parse --abbrev-ref HEAD feature/add_comission git push origin ${BRANCH_NAME} は、…
要旨 >>> frozenset(['a', 'b', 'c']).add('z') Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'frozenset' object has no attribute 'add' 詳細 fronzenset に対して add() した際は、特別なエラーではなく AttributeError が</module></stdin>…
要旨 [1] pry(main)> [1, nil, false, true].any? => true [2] pry(main)> [nil, false].any? => false 詳細 全てを検査したい場合は、 Enumerable#all? を使えば良い。 参考 docs.ruby-lang.org
要旨 class Person { constructor(name, height, weight) { this.name = name this.height = height this.weight = weight } getData () { return { name: this.name, height: this.height, weight: this.weight, } } } taro = new Person('taro', 180, 60) …
意識的に時間を作るようにしないと、最近執筆のための余裕がなくなって時間切れ、ということがちょいちょいある。 夜にその日の分を書くのではなくて、次の日の分を書いてしまうように変えなければ、と思う。
良くないニュースがあって、穏やかじゃない。
要旨 [1] pry(main)> 1.1-1.0 => 0.10000000000000009 [2] pry(main)> require 'bigdecimal' => true [3] pry(main)> BigDecimal('1.1') - 1.0 => 0.1e0 詳細 1.1 - 1.0 の結果は、Float の場合は誤差が出てしまっている。これは2進数で計算するときに生じる…
要旨 disable-pry を入力してEnterを押すと、以降の binding.pry では止まらなくなる。 $ ruby test.rb 1 From: /private/tmp/test.rb:5 : 1: require 'pry' 2: 3: (1..100).to_a.each do |i| 4: puts i => 5: binding.pry 6: end [1] pry(main)> 2 From: /p…
今週、というより今月ずっと、ちょっといっぱいいっぱいになりそうで、、、
要旨 console.table({ a: 1, b: 2, c: 3 }) console.table 詳細 入れ子になっていても、良い感じに表示してくれる。 An array of Arraysの場合 参考 developer.mozilla.org
諸般の事情でスキップします🙇
要旨 ['a', undefined, 1, null].filter(Boolean) // => ['a', 1] 詳細 filter の構文は、次のようになっている。 let newArray = arr.filter(callback(element[, index, [array]])[, thisArg]) この時、 callback に Boolean を指定すると、 Boolean(elemen…
要旨 x = 3 if 0 < x < 10: print('1桁の正の整数') >>> x = 3 >>> if 0 < x < 10: ... print('1桁の正の整数') ... 1桁の正の整数 詳細 あまり他の言語では見かけないが、こんな感じで複数条件を繋げることができる。 参考 docs.python.org
ちょっと腹痛
Ruby Enumerable#map { |item| ... } -> [object] 配列等のオブジェクトに対し、mapメソッドを呼ぶ。Arrayが返るが、Enumerable#lazyを使って下記のように書けば、遅延評価することもできる。 val = (1..99999999).lazy.map { |i| i.to_s } => #<Enumerator::Lazy: ...> val.to_a # </enumerator::lazy:>…
要旨 # 10以上の数(=最低で10)が欲しい場合 [1] pry(main)> [3, 10].max => 10 [2] pry(main)> [15, 10].max => 15 関連 blog.dogwood008.com
要旨 # 10を超えない数(=最高で10)が欲しい場合 [1] pry(main)> [3, 10].min => 3 [2] pry(main)> [15, 10].min => 10
要旨 (0..10).to_a.map(&:to_s) => ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"] 詳細 「Proc展開」 "Proc coercion" 等の名前で呼ばれていることがあるが、特定の呼び名は決まっていないようだ。 参考 docs.ruby-lang.org
要旨 [1] pry(main)> p 'test' "test" => "test" 詳細 手っ取り早く表示させるのに便利。 参考 docs.ruby-lang.org
要旨 console.log('log') console.warn('warn') console.error('error') それぞれの見た目 詳細 主要なブラウザは、全て対応している。 console.log() では埋もれてしまうくらい沢山の出力がある際、特定の出力を目立たせる時に便利。 参考 developer.mozill…
要旨 背景 用語 詳細 要旨 AWS Load Balancer Controller で指定するACMのARNが誤っていると、構成によっては502が返る。 これは、ALBのホスト名に対し直接httpsで繋ぎに行くと、ブラウザのアドレスバーからたどれる証明書を見ることで確認できる。 背景 Rou…
左目が開かないので、今日も休みます。。。
昨日は熱があったけど、今日は下がった!明日からは普段通り!
コロナではなさそう。
要旨 ^ と $ の場合 [1] pry(main)> regex = /^https:\/\/.+$/ => /^https:\/\/.+$/ [2] pry(main)> 'javascript:exploitcode() /* https://safesite.example.com */'.scan(regex) => ["https://safesite.example.com"] rubular.com \A と \z の場合 [3] pry…