|
1 2 3 4 5 6 7 8 9 10 |
RunWait, %ComSpec% /c ipconfig | clip Loop, Parse, clipboard, `n, `r { var := RegExMatch(A_LoopField, "IPv4\D*([.0-9]+)", x) if(var > 0) { MsgBox, IPアドレス:%x1% } } |
|
1 2 3 4 5 6 7 8 9 10 |
RunWait, %ComSpec% /c ipconfig | clip Loop, Parse, clipboard, `n, `r { var := RegExMatch(A_LoopField, "IPv4\D*([.0-9]+)", x) if(var > 0) { MsgBox, IPアドレス:%x1% } } |
ファイルを保存するダイアログのオプションの中に、
ISO 19005-1に準拠というのがあるので、チェックを外す。
(CubePDFが入っていて削除したくないという状態)
・AcrobatReaderから再設定
編集>環境設定>一般
・WindowsExplorerでPDFサムネイルのプレビューを有効にする
・デフォルトのPDFハンドラーを選択
この2つを一度オフにして再度オン。
・IconCache.dbのリセット
ie4uinit.exe -show
ie4uinit.exe -ClearIconCache
・CubePDFに関連あるスタートアップを停止
AutoRunsを使いすべて手動で停止。
・アプリの修復
Win10設定>アプリ>アプリと機能
から、AcrobatReaderを修正。
・エクスプローラーの一時ファイル削除
CCleanerでエクスプローラーの一時ファイルを削除。
ここまでやって駄目。
・AcrobatReaderの再インストール
Acrobat Cleaner Toolを使い再インストール。
再インストールしたら直った。素直に再インストールでいいらしい。
(一応、AcrobatReaderの再インストールはやったと聞いていたので、他の作業が影響しているかもしれない)
ファイル名を指定して実行
wsreset
を実行
control>トラブルシューティング>すべて表示>Windows ストアアプリ
実行
Win10設定>時刻と言語
正しい設定になっているか確認
Win10設定>ネットワークとインターネット>セットアップスクリプトを使う
オフになっているか確認
Win10設定>アプリ>Microsoft Store>詳細オプション>リセット
再インストール
Get-AppXPackage -AllUsers -Name Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register “$($_.InstallLocation)\AppXManifest.xml” -Verbose}
ここまで回復せず。
control>インターネットオプション>詳細設定>セキュリティ
TLS1.0
TLS1.1
TLS1.2
にチェックをつける。
これで開けた。
実験のため、ConoHa メモリ1GBプランでMattermostのテンプレートを立ち上げてみた。
SSHキー設定し忘れたのでrootパスワードを利用し、TeraTermから接続。
SSH接続とファイアーウォール設定あたりを実行。
ブラウザからアクセスし、メールアドレス、ユーザー名、パスワードを決め、チーム(Create a team)を作成する。ここで、チーム名とURLを決める。
・日本語化
メニュー>Account Settings>Display>Language
日本語に変更
システムコンソール>言語>
デフォルトのサーバー言語、デフォルトのクライアント言語の2つを
日本語に変更
・トークン発行
システムコンソール>統合機能管理
パーソナルアクセストークンを有効にする
メニュー>アカウントの設定>セキュリティ>パーソナルアクセストークン
トークンを生成する
C#にてRestAPIを利用するサンプル
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
using System.Net.Http; using System.Windows.Forms; namespace WindowsFormsApp1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); string token = "xxx"; string url = "http://xxx/api/v4/" + "users"; // 1 var client1 = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, url); request.Headers.Add("ContentType", "application/json"); request.Headers.Add("Authorization", "Bearer " + token); var response1 = client1.SendAsync(request); MessageBox.Show(response1.Result.Content.ReadAsStringAsync().Result); // 2 var client2 = new HttpClient(); client2.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token); client2.DefaultRequestHeaders.Add("ContentType", "application/json"); var response2 = client2.GetAsync(url); MessageBox.Show(response2.Result.Content.ReadAsStringAsync().Result); // 3 var client3 = new HttpClient(); client3.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); // 2とはここが違う client3.DefaultRequestHeaders.Add("ContentType", "application/json"); var response3 = client3.GetAsync(url); MessageBox.Show(response3.Result.Content.ReadAsStringAsync().Result); } } } |
同じようなソフトのRocketChatの場合。
少し操作してみただけで利用していない。
・インストール
snap install rocketchat-server
・ufw
ufw allow 3000/tcp
ufw reload
・アンイストール
snap remove rocketchat-server
・ufw
ufw status numbered(番号確認)
ufw delete 番号
ufw reload
Form1のウィンドウメッセージをPreFilterMessageにて表示+バックグラウンドでPeekMessage()を利用したループを実行。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
using System; using System.Windows.Forms; namespace WindowsFormsApp1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.Load += (s, e) => { var TestMessage = new TestMessage(); Application.AddMessageFilter(TestMessage); }; } } class TestMessage : IMessageFilter { public bool PreFilterMessage(ref Message m) { System.Diagnostics.Debug.Print(DateTime.Now.ToString("HH:mm:ss.ff") + " " + m.ToString()); return false; } } } |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace WindowsFormsApp1 { static class NativeMethods { [StructLayout(LayoutKind.Sequential)] internal struct POINT { public int x; public int y; } [StructLayout(LayoutKind.Sequential)] internal struct MSG { public IntPtr hwnd; public int message; public IntPtr wParam; public IntPtr lParam; public int time; public POINT pt; } [DllImport("user32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool PeekMessage(out MSG msg, IntPtr hWnd, int wMsgFilterMin, int wMsgFilterMax, int wRemoveMsg); } /* [DllImport("DLL名", パラメータ)] DllImportが指定されたメソッドは、指定されたDLLに存在すると解釈される ・パラメータ EntryPoint:DLL内の関数の名前 CharSet:文字列のマーシャリング方法 SetLastError:Win32エラー情報を維持するか ExactSpelling:EntryPointの関数名を厳密に一致させるか PreserveSig:T定義通りのメソッドのシグネチャを維持するか CallingConvention:EntryPointで使用するモードを指定する ・返値(受け取るとき): [return: MarshalAs(UnmanagedType.Bool)] static extern int xxx([MarshalAs(UnmanagedType.LPWStr), Out] StringBuilder lpPathName); var buff = new StringBuilder(255); NativeMethods.xxx(buff); ・引数(渡すとき): static extern bool xxx([MarshalAs(UnmanagedType.LPWStr), In] string xxx); MarshalAs() マーシャリングとは、マネージドコードとネイティブコードの間でやり取りするときに型を変換するプロセス。 */ public class TestContext : ApplicationContext { public TestContext() { var f = new Form1(); ((Button)f.Controls["btn"]).Click += (s, e) => { // バックグラウンドのループ終了 MessageBox.Show(""); Application.Idle -= this.TestLoop; }; MainForm = f; // フォームの表示方法。エントリポイントでApplication.Run(new TestContext())とした後、 // MainFormに渡すだけでOK Application.Idle += this.TestLoop; } private void TestLoop(object sender, EventArgs e) { while (!NativeMethods.PeekMessage(out NativeMethods.MSG _, IntPtr.Zero, 0, 0, 0)) { System.Diagnostics.Debug.Print("★" + DateTime.Now.ToString("HH:mm:ss.ff")); System.Threading.Thread.Sleep(1); } } } } |
EmEditorの外部ツールからAWKを呼び出すときにスクリプトファイルを選択するため。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
using System; using System.Windows.Forms; using System.IO; namespace ScriptSelector { static class Program { /// <summary> /// アプリケーションのメイン エントリ ポイントです。 /// </summary> [STAThread] static void Main() { // プロジェクトのプロパティから出力をコンソールにする。 string[] args = Environment.GetCommandLineArgs(); string arg = ""; if (args.Length == 2 && File.Exists(args[1]) && Path.GetExtension(args[1]) == ".txt") arg = args[1]; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var f = new Form1(arg); f.ShowInTaskbar = false; // EmEditor外部ツールではこれがないと固まる Application.Run(f); } } } |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
using System; using System.Diagnostics; using System.IO; using System.Windows.Forms; namespace ScriptSelector { public partial class Form1 : Form { public Form1(string textPath) { InitializeComponent(); var scriptPaths = Directory.GetFiles(@"G:\Dropbox\My Cloud Work\Text\awk", "*.awk", SearchOption.AllDirectories); foreach(string p in scriptPaths) { comboBox1.Items.Add(Path.GetFileNameWithoutExtension(p)); } comboBox1.SelectedIndexChanged += (s, e) => { using (var process = new Process()) { string file = @"G:\Dropbox\My Cloud Work\Utility\gawk 5.1\bin\gawk.exe"; string option = @"-f ""G:\Dropbox\My Cloud Work\Text\awk\" + comboBox1.Text + @".awk"" ""\n"""; if (textPath != "") option = @"-f ""G:\Dropbox\My Cloud Work\Text\awk\" + comboBox1.Text + @".awk"" """ + Path.GetFullPath(textPath) + @""""; var info = new ProcessStartInfo(file, option); info.RedirectStandardOutput = true; info.RedirectStandardError = true; info.CreateNoWindow = true; info.UseShellExecute = false; process.StartInfo = info; process.Start(); string output = process.StandardOutput.ReadToEnd(); process.StandardOutput.Close(); if (output != "") Console.Out.Write(output); } Application.ExitThread(); }; } } } |
・バイナリはここから
https://ja.osdn.net/projects/sfnet_ezwinports/releases/
・基本文法
awk “パターン文 { アクション文 }” 入力ファイル
awk -f スクリプトファイル
Winなので、ダブルクォーテーション囲い、文字列の場合エスケープする。
・パターン文
1.正規表現
‘/正規表現/ { アクション文 }’
|
1 2 3 |
@echo off gawk "/^[1-9]/ { print $0 }" "%~dpnx1" pause |
2.BEGIN-END
BEGIN { 最初の行の前の処理 }
END { 最後の行の後の処理 }
|
1 2 3 |
@echo off gawk "/^[1-9]/ { print $0 } BEGIN { print \"start\" } END { print \"end\" }" "%~dpnx1" pause |
3.条件式
条件を省略するとすべての行を処理
処理を省略すると条件がtrueの行が表示される{ print $0 }
0(ゼロ)と””(空文字)がfalse
条件を省略
|
1 2 3 |
@echo off gawk "{ print $0 }" "%~dpnx1" pause |
処理を省略
|
1 2 3 |
@echo off gawk "/^[1-9]/" "%~dpnx1" pause |
・組込変数
$0:レコード
$n:n番目のフィールド
FS:フィールド区切文字
NR:現在のレコード数
NF:現在のフィールド数
2番目のフィールドを出力
|
1 2 3 |
@echo off gawk "{ print $2 }" "%~dpnx1" pause |
・スクリプトファイルで実行する場合
|
1 2 3 |
@echo off gawk -f script.awk "%~dpnx1" pause |
|
1 2 3 4 5 6 7 8 |
BEGIN { i = 1; } /^[0-9]/ { print $0; print i "番目"; } { i++; } |
・EmEditorから実行する場合
パスを通さず直接指定している。
ツール>外部ツール>外部ツールの設定>新規作成
コマンド:G:\Dropbox\My Cloud Work\Utility\gawk 5.1\bin\gawk.exe
引数:-f “G:\Dropbox\My Cloud Work\Text\awk.txt” “$(Path)”
|
1 2 3 4 |
# スクリプトファイルで実行した場合 FILENAME ~ /awk.txt/ { exit } { print $2 } |
・C#から標準入出力で利用する場合
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
var process = new Process(); // 対象テキストをファイルで渡す場合、3つ目の引数に指定する var info = new ProcessStartInfo(@"xxx\gawk.exe",@"-f xxx.txt"); // 標準入出力リダイレクト // Write()しない場合、RedirectStandardInput不要 info.RedirectStandardOutput = true; info.RedirectStandardInput = true; info.CreateNoWindow = true; info.UseShellExecute = false; process.StartInfo = info; process.Start(); process.StandardInput.Write("hello world"); process.StandardInput.Close(); string output = process.StandardOutput.ReadToEnd(); process.StandardOutput.Close(); process.Dispose(); MessageBox.Show(output); |
・サンプル
マッチした部分を抜き出す。
|
1 2 3 |
match ($0, /^[0-9]\w*/) { print substr($0, RSTART, RLENGTH); } |
PHPの切り替えを実行。
プラグインのSyntax Highlighterがエラーになるようなので、
wp-content/plugins/crayon-syntax-highlighter/
の中にある、
crayon_langs.cclass.php
の338行目、以下のように変更。
return preg_replace(‘/[^\w-+#]/msi’, ”, $id);
return preg_replace(‘/[^\w\-+#]/msi’, ”, $id);
|
1 2 3 4 5 6 7 |
Sub test() For Each w In Sheets w.Cells.Validation.Delete Next End Sub |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
Sub test() For Each w In Sheets If w.Name = "Sheet2" Then GoTo continue With w.Range("A2:A10").Validation .Delete .Add Type:=xlValidateList, Operator:=xlEqual, Formula1:="テスト1,テスト2" End With continue: Next End Sub |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
Sub test() Set w = ActiveSheet w.Range("A2:K1000").Clear With w.Range("A2:A1000").Validation .Delete .Add Type:=xlValidateList, Operator:=xlEqual, Formula1:="=マスタ!$A$1:$A$776" End With End Sub |
いつも忘れてしまうので。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
// 通常の配列 string[] a = new string[2]; string[] b = new string[] { "a", "b" }; string[] c = new string[2] { "a", "b" }; // 配列の配列(ギザギザ配列) string[][] aa = new string[2][] { new string[]{"2","3"}, new string[]{"a","b","c"} }; // 1行目は2列 // 2行目は3列 for(int row = 0; row < aa.Length; row++) { for(int col = 0; col < aa[row].Length; col++) { MessageBox.Show(aa[row][col]); // 2,3,a,b,c } } // 多次元配列(四角い配列) string[,] bb = new string[2,4]; string[,] cc = new string[2,2] { { "a1", "a2" },{ "b1", "b2" } }; string[,] dd = new string[,] { { "a1", "a2" },{ "b1", "b2" } }; // 3行2列 string[,] ee = new string[3,2] { { "a1", "a2" }, { "b1", "b2" }, { "c1", "c2" } }; // GetLength(0) は行数 GetLength(1)は列数 MessageBox.Show(bb.GetLength(0).ToString()); // 2 MessageBox.Show(bb.GetLength(1).ToString()); // 4 |