Skip to content

Instantly share code, notes, and snippets.

@ksasao
ksasao / whoistalking.cs
Last active May 31, 2018 12:46
ML.NETで誰が言ったセリフかを推定する
// ML.NETで誰が言ったセリフかを推定する
//
// ML.NETのセットアップ方法は下記を参照
// https://www.microsoft.com/net/learn/apps/machine-learning-and-ai/ml-dotnet/get-started/windows
using Microsoft.ML;
using Microsoft.ML.Models;
using Microsoft.ML.Runtime.Api;
using Microsoft.ML.Trainers;
using Microsoft.ML.Transforms;
using System;
@ksasao
ksasao / create-vhdx.ps1
Last active July 1, 2018 01:27
Create blank .vhdx virtual disk using PowerShell
$vhdPath="sample.vhdx"
$vhdSize = 20GB
$driveLetter = "E"
$label = "Data"
$fileSystem = "NTFS"
New-VHD -Path $vhdPath -Dynamic -SizeBytes $vhdSize
Mount-VHD -Path $vhdPath
$disk = get-vhd -path $vhdPath
Initialize-Disk $disk.DiskNumber
@ksasao
ksasao / DirectoryEx.cs
Created July 2, 2018 15:15
Directory.GetLogicalDrives() does not return network drives when a process is running with administrator privileges. This code returns all logical drives including network drives whether it runs in administrator or not.
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
namespace Mpga
{
/// <summary>
/// Directory.GetLogicalDrives() does not return network drives when a process
/// is running with administrator privileges.
@ksasao
ksasao / Direct2DText.cs
Last active April 15, 2025 20:36
Draw color emoji to System.Drawing.Bitmap
using System;
using SharpDX;
using SharpDX.Direct2D1;
using SharpDX.DirectWrite;
using SharpDX.Mathematics.Interop;
using d2 = SharpDX.Direct2D1;
using d3d = SharpDX.Direct3D11;
using dxgi = SharpDX.DXGI;
using wic = SharpDX.WIC;
@ksasao
ksasao / run.csx
Last active August 19, 2018 14:38
Receive synapseWear data and post the data to Slack using Azure Functions (HTTP Trigger/C#)
#r "Newtonsoft.Json"
using System;
using System.Text;
using System.Net;
using Newtonsoft.Json;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
log.Info("C# HTTP trigger function processed a request.");
@ksasao
ksasao / function.json
Last active August 23, 2018 23:36
Receives synapseWear data and writes to Azure Table Storage
{
"bindings": [
{
"authLevel": "function",
"name": "req",
"type": "httpTrigger",
"direction": "in",
"methods": [
"post"
]
@ksasao
ksasao / Program.cs
Last active February 18, 2022 00:23
PuppeteerSharp と AngleSharp を使って C#でヘッドレスブラウザなスクレイピング
using AngleSharp.Dom.Html;
using AngleSharp.Parser.Html;
using PuppeteerSharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ksasao
ksasao / HTTPSTest.ino
Last active August 29, 2020 05:16
M5Stack HTTPS Client with Azure Functions
#include <M5Stack.h>
#include <WiFiClientSecure.h>
WiFiClientSecure client;
const char* ssid = "your SSID"; // WiFi SSID
const char* password = "your WiFi password"; // WiFi PW
const char* host = "host name (e.g. example.azurewebsites.net)";
const char* path = "url (e.g. /api/EnvMonitor?code=AAA==)";
@ksasao
ksasao / Program.cs
Created September 24, 2018 04:32
PuppeteerSharp を利用して、特定のURLをヘッドレスブラウザでダウンロードする C# コード。ビルド時には nuget で PuppeteerSharp を追加する。
using PuppeteerSharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ChromeDownload
{
@ksasao
ksasao / restart.bat
Last active October 28, 2018 04:16
Windowsバッチファイルで指定したプロセスを再起動する。タスクスケジューラに登録して定期的に実行することを想定。引数に実行したい.exeのフルパスを指定する。UNC対応。
@echo on
pushd %~dp0
set fullpath=%1
if [%1] equ [] (
echo %date% %time% "引数が指定されていません" >> restart.log
goto :END
)
call :CHECK_TASK %fullpath%
goto :END