XDG Base Directory Specification
XDG Base Directory Specificationって何
デスクトップ環境における標準的なフォルダー構造を規定した仕様
目的
煩雑になるデータを、標準的な仕様を設けることによって一貫性のある方法を提供し、整理する。
XDG Base DIrectory Specificationが規定するフォルダー
#### $XDG_DATA_HOME アプリのデータを置くフォルダーのパス.
let, const , var
目的
宣言方法一覧
- const
- let
- var
const
1度しか代入できない変数(定数)
スコープの制約がある
実行
{ const a = 1; console.log(a); }
実行結果
1
実行
{ const a = 1; a = 2; console.log(a); }
実行結果
再代入を実施するとエラーが発生する
VM498:3 Uncaught TypeError: Assignment to constant variable. at <anonymous>:3:7
実行
{ const a = 1; } console.log(a);
実行結果
スコープ外では宣言していないためエラーが発生する
VM191:1 Uncaught ReferenceError: a is not defined at <anonymous>:1:13
let
再代入可能
スコープの制約がある
実行
{ let b = 1; b = 2; console.log(b); }
実行結果
再代入され1
ではなく2
になる
2
実行
{ let b = 1; } console.log(b);
実行結果
スコープ外なのでエラーが発生する
VM346:1 Uncaught ReferenceError: b is not defined at <anonymous>:1:13
var
再代入可能
スコープの制約がない
(使用は非推奨)
実行
{ let c = 1; c = 2; console.log(c); }
実行結果
2
実行
{ let c = 1; } console.log(c);
実行結果
1
Hammerspoonによって画面分割
目的
PC上のwindowを画面上下左右に寄せたい
Hammerspoonとは
macOS上でLuaというプログラミング言語を落ちいてscriptを実行することができるソフトウェアです windowの画面分割も実施できshiftitの代替案として上がっています
参考
手順
1. Hammerspoonのダウンロード
公式サイトのHow do I install it?
の項目に沿って実施
githubリポジトリよりインストールしたいversionのHammerspoonのzipをダウンロード、その後アプリケーションフォルダへドラッグする。
2. Hammerspoonの設定
- ダウンロードしたHammerspoonを起動
- メニューバーアイコン > Preferences..
- を選択し「Launch Hammerspoon at login」をチェックする
- 「Enable Accesibility」を押して、Macの設定からHammerspoonにアクセス権を与える
- .hammerspoon/init.luaを開き下記の設定を書き込んで保存
- メニューバー(PC画面の一番上に表示されている領域)のHammerspoonを押し
Reload config
を押す
hs.window.animationDuration = 0 units = { right50 = { x = 0.50, y = 0.00, w = 0.50, h = 1.00 }, left50 = { x = 0.00, y = 0.00, w = 0.50, h = 1.00 }, top50 = { x = 0.00, y = 0.00, w = 1.00, h = 0.50 }, bot50 = { x = 0.00, y = 0.50, w = 1.00, h = 0.50 }, maximum = { x = 0.00, y = 0.00, w = 1.00, h = 1.00 } } mash = { 'shift', 'ctrl' } hs.hotkey.bind(mash, 'right', function() hs.window.focusedWindow():move(units.right50, nil, true) end) hs.hotkey.bind(mash, 'left', function() hs.window.focusedWindow():move(units.left50, nil, true) end) hs.hotkey.bind(mash, 'up', function() hs.window.focusedWindow():move(units.top50, nil, true) end) hs.hotkey.bind(mash, 'down', function() hs.window.focusedWindow():move(units.bot50, nil, true) end) hs.hotkey.bind(mash, 'm', function() hs.window.focusedWindow():move(units.maximum, nil, true) end)
- 'shift' 'control' <上下左右の何かしらのボタン> : 各矢印キー側にwindowが画面の50%で表示される
- 'shift' 'control' 'm' : 選択しているwindowが画面全体のサイズになる
SpringBoot : @RequestMappingと@GetMappingの違い
### 目的
@RequestMapping
や、@GetMapping
が記述されているけど違いがわからない
結論
@RequestMapping
GET, POST, PUT, DELETE をするURI全ての前段階のMappingを記述する
@GetMapping
例
/** * コントローラクラスであることの宣言 */ @RestController /** * リクエストURLに対しての処理メソッド定義 */ @RequestMapping("/messages") public class MessageController { /** * 他クラス呼び出し */ @Autowired private MessageService messageService; /** * RequestmappingのGet拡張(全件取得) */ @GetMapping public Collection<Message> getMessages() { return messageService.getMessages(); } /** * RequestmappingのGet拡張(idごとの取得) * * @throws NotFoundException */ @GetMapping("/{id}") public Optional<Message> getMessageById(@PathVariable String id) throws NotFoundException { return messageService.getMessageById(id); } /** * RequestmappingのPost拡張(登録) */ @PostMapping public Message postMessage(@RequestBody @Validated Message message) { return messageService.createMessage(message); } /** * RequestmappingのDelete拡張(idごとの削除) * * @throws NotFoundException */ @DeleteMapping("/{id}") public Optional<Message> deleteMessageById(@PathVariable String id) throws NotFoundException { return messageService.deleteMessageById(id); } /** * RequestmappingのPut拡張(idごとの更新) * * @throws NotFoundException */ @PutMapping("/{id}") public Optional<Message> updateMessageById(@PathVariable String id, @RequestBody MessageUpdatePayload messageUpdatePayload) throws NotFoundException { return messageService.updateMessageById(id, messageUpdatePayload); } }