karabiner elements でキーのリマップでカーソルキー設定

karabiner elements でキーのリマップでカーソルキー設定

キーボードホームポジションでカーソルキー上下左右を操作したい。
以下のようにカスタム設定したJSONを配置。(今回はkarabiner.json)

title
title

内容を記載して、ComplexModificationsでAdd ruleを選ぶとルールが追加されているはずなので、追加。

以下はその karabiner.jsonの内容

{
    "global": {
        "check_for_updates_on_startup": true,
        "show_in_menu_bar": true,
        "show_profile_name_in_menu_bar": false
    },
    "profiles": [
        {
            "complex_modifications": {
                "parameters": {
                    "basic.simultaneous_threshold_milliseconds": 10,
                    "basic.to_delayed_action_delay_milliseconds": 100,
                    "basic.to_if_alone_timeout_milliseconds": 1000,
                    "basic.to_if_held_down_threshold_milliseconds": 500
                },
                "rules": [
                    {
                        "description": "コマンドキーを単体で押したときに、英数・かなキーを送信する。(左コマンドキーは英数、右コマンドキーはかな) (rev 3)",
                        "manipulators": [
                            {
                                "from": {
                                    "key_code": "left_command",
                                    "modifiers": {
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "parameters": {
                                    "basic.to_if_held_down_threshold_milliseconds": 100
                                },
                                "to": [
                                    {
                                        "key_code": "left_command",
                                        "lazy": true
                                    }
                                ],
                                "to_if_alone": [
                                    {
                                        "key_code": "japanese_eisuu"
                                    }
                                ],
                                "to_if_held_down": [
                                    {
                                        "key_code": "left_command"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "from": {
                                    "key_code": "right_command",
                                    "modifiers": {
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "parameters": {
                                    "basic.to_if_held_down_threshold_milliseconds": 100
                                },
                                "to": [
                                    {
                                        "key_code": "right_command",
                                        "lazy": true
                                    }
                                ],
                                "to_if_alone": [
                                    {
                                        "key_code": "japanese_kana"
                                    }
                                ],
                                "to_if_held_down": [
                                    {
                                        "key_code": "right_command"
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    },
                    {
                        "description": "ctrl + k -> up_arrow",
                        "manipulators": [
                            {
                                "from": {
                                    "key_code": "k",
                                    "modifiers": {
                                        "mandatory": [
                                            "control"
                                        ],
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "up_arrow"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "from": {
                                    "key_code": "j",
                                    "modifiers": {
                                        "mandatory": [
                                            "control"
                                        ],
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "down_arrow"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "from": {
                                    "key_code": "f",
                                    "modifiers": {
                                        "mandatory": [
                                            "control"
                                        ],
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "right_arrow"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "from": {
                                    "key_code": "b",
                                    "modifiers": {
                                        "mandatory": [
                                            "control"
                                        ],
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "left_arrow"
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    }
                ]
            },
            "devices": [],
            "fn_function_keys": [
                {
                    "from": {
                        "key_code": "f1"
                    },
                    "to": {
                        "consumer_key_code": "display_brightness_decrement"
                    }
                },
                {
                    "from": {
                        "key_code": "f2"
                    },
                    "to": {
                        "consumer_key_code": "display_brightness_increment"
                    }
                },
                {
                    "from": {
                        "key_code": "f3"
                    },
                    "to": {
                        "key_code": "mission_control"
                    }
                },
                {
                    "from": {
                        "key_code": "f4"
                    },
                    "to": {
                        "key_code": "launchpad"
                    }
                },
                {
                    "from": {
                        "key_code": "f5"
                    },
                    "to": {
                        "key_code": "illumination_decrement"
                    }
                },
                {
                    "from": {
                        "key_code": "f6"
                    },
                    "to": {
                        "key_code": "illumination_increment"
                    }
                },
                {
                    "from": {
                        "key_code": "f7"
                    },
                    "to": {
                        "consumer_key_code": "rewind"
                    }
                },
                {
                    "from": {
                        "key_code": "f8"
                    },
                    "to": {
                        "consumer_key_code": "play_or_pause"
                    }
                },
                {
                    "from": {
                        "key_code": "f9"
                    },
                    "to": {
                        "consumer_key_code": "fastforward"
                    }
                },
                {
                    "from": {
                        "key_code": "f10"
                    },
                    "to": {
                        "consumer_key_code": "mute"
                    }
                },
                {
                    "from": {
                        "key_code": "f11"
                    },
                    "to": {
                        "consumer_key_code": "volume_decrement"
                    }
                },
                {
                    "from": {
                        "key_code": "f12"
                    },
                    "to": {
                        "consumer_key_code": "volume_increment"
                    }
                }
            ],
            "name": "Default profile",
            "selected": true,
            "simple_modifications": [],
            "virtual_hid_keyboard": {
                "country_code": 0
            }
        }
    ]
}

LetsEncryptの更新がうまく行かなかった(certbot-auto renew –force-renew)

LetsEncryptの更新がうまく行かなかった(certbot-auto renew –force-renew)

きちんと自動更新してなかったのもあり、証明書の期限を切らしてしまった。ちゃっと終わらそうと以下を叩くとエラー時のめも。

# certbot-auto renew --force-renew
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/yama-lab.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Plugins selected: Authenticator webroot, Installer None
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for yama-lab.com
Waiting for verification...
Challenge failed for domain yama-lab.com
http-01 challenge for yama-lab.com
Cleaning up challenges
Attempting to renew cert (yama-lab.com) from /etc/letsencrypt/renewal/yama-lab.com.conf produced an unexpected error: Some challenges have failed.. Skipping.
The following certs could not be renewed:
  /etc/letsencrypt/live/yama-lab.com/fullchain.pem (failure)

とエラーが出るの以下を実行

# certbot-auto certonly -d yama-lab.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log

How would you like to authenticate with the ACME CA?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Apache Web Server plugin (apache)
2: Nginx Web Server plugin (nginx)
3: Spin up a temporary webserver (standalone)
4: Place files in webroot directory (webroot)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-4] then [enter] (press 'c' to cancel): 2   // 2を入力Enter
Plugins selected: Authenticator nginx, Installer None
Cert is due for renewal, auto-renewing...
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for yama-lab.com
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/yama-lab.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/yama-lab.com/privkey.pem
   Your cert will expire on 2019-06-10. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again. To non-interactively renew *all* of your certificates, run
   "certbot-auto renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

で解決

WordPressの管理画面のメニューとか、ACF(AdvancedCustomFields)/CPTUI(CutomPostTypeUI)のメニューなどを非表示にする。


function remove_menus () {
    // if( current_user_can( 'editor' ) ){
        global $menu;
        unset($menu[2]);  // ダッシュボード
        unset($menu[4]);  // メニューの線1
        unset($menu[5]);  // 投稿
        unset($menu[10]); // メディア
        unset($menu[15]); // リンク
        unset($menu[20]); // ページ
        unset($menu[25]); // コメント
        unset($menu[59]); // メニューの線2
        unset($menu[60]); // テーマ
        unset($menu[65]); // プラグイン
        unset($menu[70]); // プロフィール
        unset($menu[75]); // ツール
        unset($menu[80]); // 設定
        unset($menu[90]); // メニューの線3

        remove_menu_page('edit.php?post_type=acf-field-group');
    remove_menu_page('cptui_main_menu');

    // }
}
add_action('admin_menu', 'remove_menus');

ASK CLI(Alexa Skills Kitコマンドラインインターフェース)で、東京リージョンのLambdaにデプロイ(UPDATE)する

askコマンドでリージョン指定ができないなーと。‘~/.aws/config’ とかに設定しても見てない様子だったので、ソース追いかけたらシェルの環境変数を見ているみたい。

ask-cli/lib/utils/init-aws.js の87行目あたりの ‘getCLICompatibleDefaultRegion’ 関数で、region取得している。

 let region = process.env.AWS_REGION || process.env.AMAZON_REGION || process.env.AWS_DEFAULT_REGION || process.env.AMAZON_DEFAULT_REGION; 

~/.bashrc当りに追記してあげればOKでした。

export AWS_REGION=ap-northeast-1

して反映と確認。

$ source ~/.bashrc
$ echo $AWS_REGION
ap-northeast-1

参考URL :
Alexa Skills Kitコマンドラインインターフェース(ASK CLI)リファレンス
https://developer.amazon.com/ja/docs/smapi/ask-cli-command-reference.html

WordPressでカスタム投稿タイプを管理画面で任意にソート(オーダー)する

<?php

is_admin() && add_action( 'pre_get_posts', 'extranet_orderby' );

function extranet_orderby( $query )
{
    // Nothing to do:  
    if( ! $query->is_main_query() || 'people' != $query->get( 'post_type' )  )
        return;
    $orderby = $query->get( 'orderby');
    $query->set( 'orderby',  'data' );
    $query->set( 'order',  'ASC' ); 
}

WordPressでカスタム投稿タイプを一覧表示で並び替え

$query1 = new WP_Query([
    'post_type' => 'people',
    'posts_per_page' => -1,
    'orderby' => 'date',
    'order' => 'ASC',
]);
if ($query1->have_posts()):
while ($query1->have_posts()) :
    $query1->the_post();
?>
    <h2><?php the_title(); ?></h2>
<?php
endwhile;
endif;
?>

WordPressの固定ページでテンプレートのプルダウンが表示されない場合。

いろいろ試すが出ない、よくよく見ると テーマの index.phpが無かった。
中身は無くても配置するだけで出てくれる。

トップページや一覧ページを専用にしていたので、気づかなかった。>< (front-page,archive.php etc)

Alexaの音声合成マークアップ言語(SSML)でMP3が再生されなかった。ときのmp3形式変換方法

次のように

return handlerInput.responseBuilder
    .speak('ようこそ。なにか質問してくださいねっ。<audio src="https://example.com/bgm.mp3" />')
    .getResponse();

“スキルがリクエストに正しく応答できませんでした”とのこと。
マニュアル読み進めると

  • ビットレート
  • サンプルレート
  • コーデック

など指定がある模様、でffmpegコマンドで変換

% ffmpeg -i bgm.mp3 -ac 2 -codec:a libmp3lame -b:a 48k -ar 16000 bgm-converted.mp3

参考URL : 音声合成マークアップ言語(SSML)のリファレンス
https://developer.amazon.com/ja/docs/custom-skills/speech-synthesis-markup-language-ssml-reference.html#amazon-effect

Alexa スキル開発で外部Json定義からIntentHandlerを生成する。

Alexa スキル開発で外部Json定義からIntentHandlerを生成する。

やりたいこと、

  1. WordPressから発話を更新
  2. Lambda関数にJsonを自動デプロイ
  3. Lambda関数ではJsonデータを読み込みそれからIntenteHandlerを生成

今回はの3の部分をメモ。

データのJson

{
    "CheckOutIntent": {
        "speechText":"チェックアウトは11:00です。"
    },
    "WifiIntent": {
        "speechText":"SSIDはn,a,m,u,r,a,です。パスワードは、g,u,e,s,tです。"
    }
}

汎用的にIntenteHandlerを生成する関数類を準備

var isCanIntentName = function(handlerInput,name){
    return handlerInput.requestEnvelope.request.type === 'IntentRequest'
        && handlerInput.requestEnvelope.request.intent.name === name;
};

var simpleResponce = function(handlerInput,speechText,repromptText){
    if(typeof repromptText == 'undefined'){
        return handlerInput.responseBuilder
            .speak(speechText)
            .getResponse();
    }else{
        return handlerInput.responseBuilder
            .speak(speechText)
            .reprompt(repromptText)
            .getResponse();
    }
};

var makeSimpleHnaler = function(intentName,speechText,repromptText){
    return {
        canHandle(handlerInput) {
            return isCanIntentName(handlerInput,intentName);
        },
        handle(handlerInput) {
            return simpleResponce(handlerInput, speechText,repromptText);
        }
    };
};

メイン処理

 //データ読み込み
var data = require('./data.json'); 

//builderにわたすインテントを入れる配列 : 優先の高いLaunchRequestHandler入れておく。
var intents = [
    LaunchRequestHandler
];

//dataをループにしてintentsにpush()する。
_.each(data,(intent,key)=>{
    let i = makeSimpleHnaler(key,intent.speechText);
    intents.push(i);
});

//優先度の低いEnd,SessionEnded,Errorなどのハンドラー追加
intents = [...intents,EndHandler, SessionEndedRequestHandler, ErrorHandler];

//builderにわたす
exports.handler = Alexa.SkillBuilders.standard()
    .addRequestHandlers(...intents)
    .lambda();

AlexaのSkill開発でのaddRequestHandlersに配列を渡す方法

addRequestHandlers()でなくaddRequestHandler()で代用とかいろいろ考えたのですが、スプレッド演算子で簡単でした。

exports.handler = Alexa.SkillBuilders.standard()
    .addRequestHandlers(...[
        LaunchRequestHandler,
        CheckoutHandler,
        WifiHandler,
        EndHandler,
        ErrorHandler,
        SessionEndedRequestHandler])
    .lambda();

参考 : スプレッド構文
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Spread_syntax

Page 7 of 46

Powered by WordPress & Theme by Anders Norén