概要
Could not kickstart service "com.apple.audio.coreaudiod": 1: Operation not permitted
というエラーが出てアップグレードできなかったので対策方法を紹介します
環境
- macOS 14.5
- blackhole-2ch 0.6.0
対応方法
-
rm -rfi /opt/homebrew/Caskroom/blackhole-2ch/
- brew reinstall blackhole-2ch
Could not kickstart service "com.apple.audio.coreaudiod": 1: Operation not permitted
というエラーが出てアップグレードできなかったので対策方法を紹介します
docker scout はイメージの脆弱性をスキャンしてくれるツールです
docker のバージョンがある程度最新であればデフォルトで使えます
また dockerhub でもフリープランであれば3イメージまで scout スキャンを設定することができます
今回は Mac 上で動かして脆弱性に対応してみました
バージョン24であれば特にインストールは不要でいきなり使えます
結果は以下の通りです
INFO New version 1.9.3 available (installed version is 0.16.1)
✓ Pulled
✓ Image stored for indexing
✓ Indexed 630 packages
Your image ruby:3.1.2 │ 7C 69H 134M 136L 11?
Base image buildpack-deps:bullseye │ 6C 64H 132M 136L 11?
Refreshed base image buildpack-deps:bullseye │ 1C 2H 3M 157L 3?
│ -5 -62 -129 +21 -8
Updated base image buildpack-deps:stable │ 1C 2H 3M 103L 3?
│ -5 -62 -129 -33 -8
What's Next?
Learn more about vulnerabilities → docker scout cves ruby:3.1.2
Learn more about base image update recommendations → docker scout recommendations ruby:3.1.2
これを実行すると対応方法を教えてくれます
基本はベースイメージを変更することで脆弱性に対応できるので dockerhub でベースイメージの別タグを探すと良いです
https://hub.docker.com/_/ruby/tags?page=&page_size=&ordering=&name=3.1.2 例えば 3.1.2 であれば 3.1.2-alpine3.14 にするだけでかなり減ります
INFO New version 1.9.3 available (installed version is 0.16.1)
✓ Pulled
✓ Image stored for indexing
✓ Indexed 128 packages
Your image ruby:3.1.2-alpine3.14 │ 2C 8H 8M 0L
Base image alpine:3.14 │ 1C 2H 5M 0L
Updated base image alpine:3.20 │ 0C 0H 2M 0L 1?
│ -1 -2 -3 +1
What's Next?
Learn more about vulnerabilities → docker scout cves ruby:3.1.2-alpine3.14
Learn more about base image update recommendations → docker scout recommendations ruby:3.1.2-alpine3.14
ただベースイメージを変更するとイメージ内で使用するコマンドも変わってくるのでベースイメージを変更した場合は Dockerfile などを書き換える必要がでてきます
3.1.2 -> 3.2.4 にすることで更に脆弱性を減らせます
INFO New version 1.9.3 available (installed version is 0.16.1)
✓ Provenance obtained from attestation
✓ SBOM obtained from attestation, 127 packages indexed
✓ Pulled
Your image ruby:3.2.4-alpine3.20 │ 0C 0H 3M 0L 1?
Base image alpine:3.20 │ 0C 0H 2M 0L 1?
What's Next?
Learn more about vulnerabilities → docker scout cves ruby:3.2.4-alpine3.20
docker scout を試してみました
基本的に脆弱性が出たらベースイメージを変更することを検討しましょう
またイメージで使われているツールやソフトウェアの CVE もチェックできるのでソフトの脆弱性をチェックしたい場合は以下のコマンドを使いましょう
答え: Skype for cloud からダウンロードしましょう
Mac、iPhone の Skype では再生もダウンロードもできない状態です
なぜか Mac 上だと再生もダウンロードもできません
ダウンロードしようとすると「ダウンロードに失敗しました」と表示されます
ここhttps://web.skype.com/?openPstnPage=true にログインするとブラウザで Skype が使えます
ここからだとダウンロードも再生もできました
Skype for Mac だとうまくダウンロードできない場合には Skype for cloud を試してみてください
それでもダメな場合は Windows クライアントなども試す価値はありそうです
前回指定の日時にcronが実行されるかどうかチェックするスクリプトを作成しました
今回は更にそれを応用して指定の cron が一日に何回実行されるのかカウントしてみました
from datetime import datetime, timedelta
from croniter import croniter
def count_run_today(cron_expression, target_date: str):
# 指定の日付の開始、指定の日付の明日の開始時刻を取得
target_datetime = datetime.strptime(target_date, "%Y/%m/%d")
today_start = datetime(
target_datetime.year, target_datetime.month, target_datetime.day
) - timedelta(seconds=1)
tomorrow_start = today_start + timedelta(days=1) + timedelta(seconds=1)
# cron オブジェクトの作成
cron = croniter(cron_expression, today_start)
# 当日内に実行される日時の分だけカウントする
run_count = 0
while True:
# 次に実行される日時を取得
next_run = cron.get_next(datetime)
if today_start < next_run < tomorrow_start:
run_count += 1
else:
break
return run_count
# テスト正常系
print("正常系テスト")
print(count_run_today("0 12 * * *", "2024/06/24")) # => 1
print(count_run_today("0 12 24 6 *", "2024/06/24")) # => 1
print(count_run_today("*/1 * * * *", "2024/06/24")) # => 1440
print(count_run_today("*/5 * * * *", "2024/06/24")) # => 288
print(count_run_today("*/30 * * * *", "2024/06/24")) # => 48
print(count_run_today("*/30 1 * * *", "2024/06/24")) # => 2
当日分の cron が正しく全件実行されるか確認したいときに使えるスクリプトです
例えば */5 * * * * は本日実行される cron で 30 12 22 6 * は本日実行されない cron というのを判定することができるスクリプトを紹介します
from datetime import datetime, timedelta
from croniter import croniter
def will_run_today(cron_expression):
# 今日の日付と今日の開始、明日の開始時刻を取得
now = datetime.now()
today_start = datetime(now.year, now.month, now.day) - timedelta(seconds=1)
tomorrow_start = today_start + timedelta(days=1) + timedelta(seconds=1)
# cron オブジェクトの作成
cron = croniter(cron_expression, today_start)
# 次に実行される日時を取得
next_run = cron.get_next(datetime)
# 次に実行される日時が今日中であればTrueを返す
return today_start < next_run < tomorrow_start
# テスト正常系(2024/06/21(木)に実行した想定)
print("正常系テスト")
print(will_run_today("0 12 * * *"))
print(will_run_today("*/5 * * * *"))
print(will_run_today("*/1 * * * *"))
print(will_run_today("*/30 * * * *"))
print(will_run_today("*/30 5 * * *"))
print(will_run_today("*/30 5 * 6 *"))
print(will_run_today("*/30 5 * 6 *"))
print(will_run_today("59 23 21 6 *"))
print(will_run_today("59 23 * * 5"))
print(will_run_today("59 23 21 6 5"))
print(will_run_today("1 0 21 6 5"))
print(will_run_today("0 0 * * *"))
print(will_run_today("0 0 21 6 5"))
print(will_run_today("*/30 * * * 1-5"))
# テスト異常系
print("異常系テスト")
print(will_run_today("0 12 3 2 *"))
print(will_run_today("0 12 22 6 *"))
print(will_run_today("*/5 * 22 6 *"))
print(will_run_today("*/1 * * * 4"))
print(will_run_today("*/1 * * * 0,1,2,3,4,6"))
print(will_run_today("30 12 22 * *"))
from datetime import datetime, timedelta
from croniter import croniter
def will_run_today(cron_expression, target_date: str):
# 指定の日付の開始、指定の日付の明日の開始時刻を取得
target_datetime = datetime.strptime(target_date, "%Y/%m/%d")
today_start = datetime(
target_datetime.year, target_datetime.month, target_datetime.day
) - timedelta(seconds=1)
tomorrow_start = today_start + timedelta(days=1) + timedelta(seconds=1)
# cron オブジェクトの作成
cron = croniter(cron_expression, today_start)
# 次に実行される日時を取得
next_run = cron.get_next(datetime)
# 次に実行される日時が指定日時内であればTrueを返す
return today_start < next_run < tomorrow_start
# テスト正常系(2024/06/21(木)に実行した想定)
print("正常系テスト")
print(will_run_today("0 12 * * *", "2024/06/21"))
print(will_run_today("0 12 3 2 *", "2024/02/03"))
print(will_run_today("*/1 * * * *", "2024/01/01"))
print(will_run_today("0 0 * * *", "2024/01/01"))
# テスト異常系
print("異常系テスト")
print(will_run_today("0 12 22 6 *", "2024/06/21"))
cron が大量にありその中で本日実行されるのが何個あるのかチェックしたりするのに使えます
Slidev は markdown でスライドが作成できるツールです
今回は簡単な使い方を紹介します
適当な markdown を作成しましょう
ファイル名は slides.md にします
# Slidevへようこそ!
開発者のためのプレゼンテーションスライド
---
# Page 2
- 📄 スライドを1つのMarkdownファイルで
- 🌈 テーマ、コードブロック、インタラクティブなコンポーネント
- 😎 詳しくはドキュメントをご覧ください!|
docker run --name slidev --rm -it \
--user node \
-v ${PWD}:/slidev \
-p 3030:3030 \
-e NPM_MIRROR="https://registry.npmmirror.com" \
tangramor/slidev:latest
マウントしているカレントに node_modules なども作成されるので注意しましょう
次回以降同じディレクトリで動作しないと再度作成されてしまいます
http://localhost:3030/ にアクセスするとスライドが確認できます
セクションが長すぎると画面をはみ出てしまうのではみ出る場合はセクション内の文章を短くしましょう
少し記法が特殊な部分があるのでそこは対応が必要です
YAML ヘッダなどは使えます
前回 dockerhub に push するアクションを作成しました
今回は rubygems に push するアクションを作成しました
name: ci
on:
workflow_dispatch:
inputs:
rubygems-otp-code:
description: RubyGems OTP code
required: true
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2
- run: bundle install
- name: Setup git config
run: |
git config --global user.email "your-github-email-address@xxx.com"
git config --global user.name "your-github-name"
- name: git
run: |
git status
git diff
- name: Publish to RubyGems
run: bundle exec rake release
env:
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
設定 -> API キー
で作成できます
rubygems に push できる権限を扶養しましょう
リポジトリのシークレットに登録します
自分のプロジェクト -> Settings -> Secrets and variables -> Actions -> Repository secrets -> New repository secret
ローカルの開発環境が Mac の場合 nokogiri など darwin 用のパッケージがインストールされます
nokogiri (1.16.6-x86_64-darwin)
racc (~> 1.4)
この状態の Gemfile.lock で Github Actions 上の Ubuntu で bundle install を実行すると linux 用の nokogiri がインストールされます
+ nokogiri (1.16.6-x86_64-linux)
+ racc (~> 1.4)
Github Actions では必ずこれがインストールされてしまうので事前に Mac 上で Linux 用のパッケージも追加してあげる必要があります
Rubygems で 2auth を有効にしている場合はワンタイムパスワードを入力する必要があります
env に GEM_HOST_OTP_CODE: ${{ github.event.inputs.rubygems-otp-code }} を追加することでアクション実行時にワンタイムパスワードを入力することができるのでこれで対応します
version.rb や bundle update をして何かしら更新しましょう
そして Github に push します
今回ワークフローは手動でなので手動実行します
さらにワンタイムパスワードを入力しましょう
するとワークフローが実行されて version.rb に記載した新しいバージョンの gem が公開されていることが確認できると思います
Github Actions で rubygems に自動で push してみました
master に push されると自動で実行されます
Rubygems の API キーには有効期限があるので切れた場合は再度 Github に登録してあげましょう