Skip to content

Instantly share code, notes, and snippets.

@ksasao
ksasao / meshi.cs
Created April 16, 2015 16:51
C#による 飯テロ判定コード。 License: WTFPL
using System;
using System.Drawing;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
namespace Meshi
{
// IBM Watson (Bluemix) を利用した飯画像判定
@ksasao
ksasao / udp-play.py
Last active September 2, 2015 15:11
UDPの特定のポートを時刻付きで録画再生。 License: WTFPL
# -*- coding: utf-8 -*-
import socket
import sys
import time
host = '127.0.0.1'
port = 21730
# open file
argvs = sys.argv
@ksasao
ksasao / AutoZipUpload.cs
Last active November 15, 2015 00:51
指定したフォルダにあるファイルをZIPで固めて定期的にアップロードするコード。
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace Mpga.IO
@ksasao
ksasao / Program.cs
Created December 2, 2015 11:41
Tobii EyeXDotNet の Minimal Samples/MinimalGazeDataStream/Program.cs を改変して画面を見つめることでクリックできるようにしたコードです。
namespace MinimalGazeDataStream
{
using EyeXFramework;
using System;
using System.Runtime.InteropServices;
using Tobii.EyeX.Framework;
public class NativeMethods
{
[System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "SetCursorPos")]
@ksasao
ksasao / WordExtractor.cs
Last active December 27, 2015 12:26
Googleの画像検索結果の文字列から主要な語句を自動抽出するコード。License WTFPL。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mpga.ML
{
/// <summary>
/// Google 画像検索の検索結果文字列向け単語抽出クラス
@ksasao
ksasao / ImageVector.cs
Last active January 17, 2022 02:41
C#による高速画像一致検索クラス。フル版は https://github.com/ksasao/Gochiusearch にあります。
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
@ksasao
ksasao / GDIPlusBitmapToByteArray.cs
Last active April 20, 2021 11:10
C# で Bitmap を高速に直接操作するためのあれこれ http://d.hatena.ne.jp/ksasao/20131216/1387134321 も参照
/// <summary>
/// Bitmapをbyte[]に変換する
/// </summary>
/// <param name="bitmap">変換元の32bitARGB Bitmap</param>
/// <returns>1 pixel = 4 byte (+3:A, +2:R, +1:G, +0:B) に変換したbyte配列</returns>
public byte[] BitmapToByteArray(Bitmap bmp)
{
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
System.Drawing.Imaging.BitmapData bmpData =
bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite,
@ksasao
ksasao / KairuPlayCommand.txt
Last active August 21, 2021 15:35
Office のイルカことカイル(Kairu) のモーション一覧です。* 印はループモーションのため、停止するには Stop を送る必要があります。https://blogs.technet.microsoft.com/junichia/2009/12/14/powershell-com-windows-7-msagent/ にある Play() の中身の文字列に相当します( * は不要ですので省略してください)。
# MS Agent
# https://msdn.microsoft.com/en-us/library/ms695784(v=vs.85).aspx
# Animation Lists for the Characters Available from Microsoft
# https://msdn.microsoft.com/en-us/library/ms695821(v=vs.85).aspx
Alert
CheckingSomething *
Congratulate
DeepIdle1
EmptyTrash
Explain
@ksasao
ksasao / Kanji2Yomi.cs
Last active September 11, 2023 07:04
C#による漢字→かな変換。参照>COMで、Microsoft Excel XX.X Object Library を参照に追加する。
using System;
using System.IO;
using System.Runtime.InteropServices;
using ExcelApplication = Microsoft.Office.Interop.Excel.Application;
using Microsoft.VisualBasic;
namespace Kanji2Yomi
{
class Program
{
@ksasao
ksasao / Wav2Text.cs
Created July 24, 2016 15:50
C#による音声ファイル(.wav)→テキスト変換。参照>アセンブリで、System.Speech を参照に追加する。
using System;
using System.Speech.Recognition;
using System.Text;
namespace Wav2Text
{
class Program
{
static void Main(string[] args)
{