Skip to content

Instantly share code, notes, and snippets.

module Persimmon.FsCheck
open Persimmon
open FsCheck
open System.Diagnostics
open FsCheck.Random
open System
type FsCheckConfig = {
MaxTest : int
@hafuu
hafuu / Fake.Testing.Persimmon.fsx
Last active June 25, 2018 01:48
fake.testing.persimmon.fsx の試作
namespace Fake.Testing
#if !FAKE
#load "../../../../.fake/build.fsx/intellisense.fsx"
#r "netstandard"
#endif
[<RequireQualifiedAccess>]
module Persimmon =
open System
@hafuu
hafuu / add_nuget_setting.fs
Created October 18, 2017 05:38
プロジェクトファイルにnugetの設定を追加するスクリプト
#r "system.xml.linq"
open System.IO
open System.Xml.Linq
let projectFiles =
[
for dir in Directory.GetDirectories(".") do
yield! Directory.GetFiles(dir, "*.fsproj")
yield! Directory.GetFiles(dir, "*.csproj")
> System.Text.Encoding.Default.WebName;;
val it : string = "shift_jis"
@hafuu
hafuu / list_fs_packages.fsx
Created May 10, 2016 06:46
list_fs_packages.fsx
#r "System.Net.Http"
#r "System.Xml"
#r "System.Xml.Linq"
open System
open System.Net.Http
open System.Xml.Linq
let client = new HttpClient()
@hafuu
hafuu / InferredFloatRepro.fs
Created February 5, 2016 19:18
InferredFloatRepro.fs
module InferredFloatRepro
open Microsoft.FSharp.Compiler.SourceCodeServices
open System.IO
let inferredFloatFunction x = 0.0 + x
let annotatedFloatFunction (x: float): float = 0.0
let inferredIntFunction x = 0 + x
type Dummy = Dummy
@hafuu
hafuu / random.sql
Created February 3, 2016 06:05
ランダム in 再帰CTE
DECLARE @a AS bigint = 1103515245;
DECLARE @b AS bigint = 12345;
DECLARE @c AS bigint = 2147483647;
DECLARE @x AS bigint = (@a * 3 + @b) % @c;
DECLARE @y AS bigint = (@a * @x + @b) % @c;
WITH t AS(
SELECT
0 AS Id
@hafuu
hafuu / prototype.fsx
Last active January 21, 2016 16:17
FSharpApiSearchのプロトタイプ
(*
Prefixを導入した理由は、同じ'aでもqueryとtargetの'aは別物としたい。
例)
query: string -> 'a -> 'a
target: 'a -> int -> int
この場合マッチして欲しい。
'aを同じとしてしまうと、string = 'a = intとなってマッチしない。
*)
type Prefix = Target | Query
type Type =
@hafuu
hafuu / print_page.fsx
Created March 25, 2015 05:23
yuitoのアレ
let beginPage = fsi.CommandLineArgs.[1] |> int
let endPage = fsi.CommandLineArgs.[2] |> int
let actualBeginPage = function
| 1 -> 1
| n -> (n - 2) / 4 * 2 + 3
let actualEndPage n = actualBeginPage n + 1
printfn "%d-%d" (actualBeginPage beginPage) (actualEndPage endPage)
@hafuu
hafuu / reset_timestamp.fsx
Created March 25, 2015 04:35
指定したディレクトリ配下のタイムスタンプをリセットするスクリプト
open System
open System.IO
let rec resetDirectory (timestamp: DateTime) path =
printfn "%s" path
Directory.SetCreationTime(path, timestamp)
Directory.SetLastAccessTime(path, timestamp)
Directory.SetLastWriteTime(path, timestamp)