お知らせ
現在サイトのリニューアル作業中のため、表示が崩れているページが存在することがあります。
フックを単体でテストするケースを想定。
このパターンはコンポーネントからフックを切り離しているケースで有用。手法としては@testing-library/react-hooksのrenderHook()を使う。
export const useUserForm = () => {
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
const onChangeUserName = (ev: string) => {
setUsername(ev);
};
const onChangePassword = (ev: string) => {
setPassword(ev);
};
return {
username,
password,
onChangeUserName,
onChangePassword,
};
};
it('onChangeUserName で username が設定されること', () => {
// `renderHook` で Hook をレンダリング
const { result } = renderHook(() => useUserForm());
// `act()` で Hook のイベントを叩く
act(() => result.current.onChangeUserName('foo'));
// 結果を見る
expect(result.current.username).toBe('foo');
});
System.ReactiveをNuGetから入れるthis.ticker= Observable.Interval(new TimeSpan(0, 0, 15));でObserverを作るthis.ticker.Subscribe(
(item) => {
// 任意のコントロールを操作する例
// this.Invokeでコントロールを操作するメソッドを呼び出すと実現できる
this.Invoke(
(MethodInvoker)(delegate () {
// ここに処理
})
);
}
);
どうでもいいけどRx.NETってちゃんとしたリファレンスなくね?
%HOMEPATH%.ssh\configに以下のように設定すると踏み台サーバーを経由したSSH接続が可能
ssh target-host.devとすると踏み台経由でアクセス可能
ProxyCommandではssh.exeをフルパスで記述する必要がある# Read more about SSH config files: https://linux.die.net/man/5/ssh_config
Host proxy.ssh-host.dev
HostName proxy.ssh-host.dev
User foo
IdentityFile C:\Users\user-name\.ssh\id_rsa
ForwardAgent yes
Host target-host.dev
Hostname target-host.dev
User bar
ProxyCommand C:\Windows\System32\OpenSSH\ssh.exe -l %r -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null proxy.ssh-host.dev -W %h:%p
余計な例外を投げてくるのが面倒なのでそれを無視できるように
| Env | Ver |
|---|---|
| PHP | 7.1.3 |
| Xdebug | 2.9.4 |
| VSCode | 1.48.0 |
"ignore"セクションを追加してそこに書いたファイルから出た例外は無視される
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9001,
"ignore": [
"**/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php"
]
}
]
}
VSCodeのRemote - SSH拡張でSSH接続する時に毎回秘密鍵のパスフレーズを求められるのが面倒すぎるので、パスフレーズを記憶させて入力を省略させる方法を調べた
Set-Service ssh-agent -StartupType Automatic
Start-Service ssh-agent
Get-Service ssh-agent
ssh-add C:\Users\hoge\.ssh\id_rsa
ssh-add -l
以下の警告が流れてうまく行かないケース、この場合はWindows付属のOpenSSHが腐っているので入れ替える
warning: agent returned different signature type ssh-rsa (expected rsa-sha2-512)
Get-Service -Name ssh-agent | Stop-Service
sc.exe delete ssh-agent
Remove-WindowsCapability -Online -Name "OpenSSH.Client~~~~0.0.1.0"
Remove-WindowsCapability -Online -Name "OpenSSH.Server~~~~0.0.1.0"
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install openssh --package-parameters="/SSHAgentFeature"
ssh-agentが実行中で自動起動するようになっていることを確認ssh-add C:\Users\hoge\.ssh\id_rsa
ssh-add -l