Skip to content

Instantly share code, notes, and snippets.

View sayurin's full-sized avatar

Kurata Sayuri sayurin

  • Japan
  • 17:07 (UTC +09:00)
View GitHub Profile
@sayurin
sayurin / Dialog.h
Last active December 4, 2017 23:42
#pragma once
#include <array>
#include <type_traits>
#include <Windows.h>
#include <windowsx.h>
template<int... controls>
struct Controls;
template<class RightAnchoredControls, class BottomAnchoredControls, class StretchingControls>
module Sayuri.Drawing.Png
open FSharp.NativeInterop
open System
open System.Buffers
open System.Buffers.Binary
open System.Drawing
open System.Drawing.Imaging
open System.IO
open System.IO.Compression
open System.IO.Hashing
@sayurin
sayurin / dict.fs
Created December 26, 2016 09:34
dict関数のコンピュテーション式バージョン。一旦 seq<key, value> 型に変換せずに直接 Dictionay<key, value> を作成する。
open System
open System.Collections.Generic
type State<'Key, 'Value when 'Key : equality> =
| Dict of Dictionary<'Key, 'Value>
| Item of 'Key * 'Value
| Empty
type DictBuilder<'Key, 'Value when 'Key : equality> (equalityComparer : _ IEqualityComparer) =
let create () = Dictionary<'Key, 'Value> equalityComparer
module Program =
let rec Main args =
let numbers : obj[] =
[| 0b1; 0b10; ([| 0b100; 0b1000 |] : obj[]); // binary literals
0b10000; 0b100000 |] // digit separators: not supported
let sum, count = Tally(numbers) // deconstruction
printfn "Sum: %d, Count: %d" sum count
and Tally (values : obj[]) = // tuple types
let mutable r = 0, 0 // tuple literals
@sayurin
sayurin / tinyBase64Decoder.fs
Last active June 29, 2016 22:25 — forked from alphaKAI/tinyBase64Decoder.fs
Tiny Base64 Decoder in F#
module tinyBase64Decoder
open System
open System.Collections.Generic
// Declare fundamental functions
// Generate n length Integer List (0 upto n - 1)
let iota n = [0..n-1]
// Generate n length List of x
#pragma once
#include <future>
#ifdef USE_AWAIT
#include <experimental/resumable>
#include <boost/asio/use_future.hpp>
#else
#include <exception>
#include <memory>
#include <type_traits>
#include <utility>
#include <cmath>
#include <thread>
#include <Windows.h>
#include <MMSystem.h>
#pragma comment(lib, "winmm")
struct MultiMediaTimer {
static const wchar_t* name;
static LARGE_INTEGER elapsed[10000];
static int idx;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Windows.Forms;
using Sayuri.IO;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
using IDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;
#include <iostream>
#include <string_view>
#include <wrl/client.h>
#include <mfapi.h>
#include <mftransform.h>
#include <wincodec.h>
#pragma comment(lib, "mfplat.lib")
#pragma comment(lib, "mfuuid.lib")
#pragma comment(lib, "Windowscodecs.lib")
using namespace std::literals;
@sayurin
sayurin / SocketExtensions.fs
Last active August 29, 2015 14:12
Socket Extension Methods for F# async.
module Sayuri.Net.SocketExtensions
open System
open System.Net
open System.Net.Sockets
#if NET4
type private ConcurrentBag<'T> = System.Collections.Concurrent.ConcurrentBag<'T>
#else
type private ConcurrentBag<'T>() =
let bag = System.Collections.Generic.Stack<'T>()