Skip to content

Instantly share code, notes, and snippets.

View sayurin's full-sized avatar

Kurata Sayuri sayurin

  • Japan
  • 23:31 (UTC +09:00)
View GitHub Profile
@sayurin
sayurin / GifDumper.fs
Created August 9, 2013 23:23
とりあえずGIFの情報をダンプするだけ。 情報の整合性はチェックしてません。 Extensionsは最低限しか実装してないからまだ不足がある。
open System
open System.IO
let dumpGif (bytes : byte[]) =
let i = ref 0
let byte () =
let byte = bytes.[!i]
incr i
int byte
let uint16 () =
@sayurin
sayurin / JsonSerializer.fs
Last active December 21, 2015 18:39
型安全?なJsonパーサ
module Sayuri.JsonSerializer
open System
open System.Collections.Generic
open System.Globalization
open System.Text
[<CompilationRepresentation(CompilationRepresentationFlags.UseNullAsTrueValue)>]
type JsonType =
| JsonNull
| JsonBoolean of bool
@sayurin
sayurin / CsPoh.cs
Last active December 30, 2015 11:18
ブログ記事 http://sayurin.blogspot.com/2013/12/c.html 新人女子プログラマの書いたコードを直すだけの簡単なお仕事です!|paizaオンラインハッカソンVol.1 https://paiza.jp/poh/ec-campaign
using System;
using System.Runtime.InteropServices;
static class CsPoh {
static int Calculate(byte[] buffer, byte[] prices) {
int ii = 0, oi = 0, temp;
var itemCount = 0;
while ((temp = buffer[ii++] - '0') >= 0)
itemCount = itemCount * 10 + temp;
@sayurin
sayurin / gist:7836635
Created December 7, 2013 02:38
あんまり速くなかった…
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Linq" #>
<#@ output extension=".cs" #>
using System.Reflection;
class UnsafePoh {
static readonly byte[] bytes = new byte[]{
<#= string.Join(Environment.NewLine, File.ReadAllBytes(Host.ResolvePath("Unsafe.dll")).Select((b, i) => new { b, i }).GroupBy(a => a.i / 16, a => string.Format("0x{0:X2}, ", a.b), (_, g) => string.Concat(g))) #>
#ifdef _MSC_VER
#define IO_H "io.h"
#define _CRT_NONSTDC_NO_WARNINGS
#define __attribute__(X)
#else
#define IO_H "unistd.h"
#define __pragma(X)
#define __declspec(X)
#define __fastcall
#endif
namespace Sayuri
open System
open System.Net
open System.Security.Cryptography
open System.Text
type ParameterType =
| ProtocolString of string
| QueryString of string
| BodyString of string
@sayurin
sayurin / GridViewSort.cs
Created September 10, 2014 14:11
Automatically sort library for WPF ListView (GridView).
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
namespace Sayuri.Windows {
public static class GridViewSort {
class SortIcon : Adorner {
@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>
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