Skip to content

Instantly share code, notes, and snippets.

@hafuu
hafuu / rename_column_name_by_comments.sql
Created July 4, 2012 06:23
コメントをテーブル名、カラム名にする
SELECT
tables.name
, columns.name
, table_comments.value
, column_comments.value
, 'EXEC sp_rename ''' + CONVERT(varchar, tables.name) + '.' + CONVERT(varchar, columns.name) + ''', ''' + CONVERT(varchar, column_comments.value) + ''' , ''COLUMN'';'
FROM
sys.tables AS tables
INNER JOIN sys.columns AS columns ON
tables.object_id = columns.object_id
WITH
Input(date, star) AS (
SELECT '2013-04-01', 0
UNION ALL SELECT '2013-04-03', 1
UNION ALL SELECT '2013-04-04', 1
UNION ALL SELECT '2013-04-05', 0
UNION ALL SELECT '2013-04-06', 1
UNION ALL SELECT '2013-04-07', 1
UNION ALL SELECT '2013-04-08', 1
UNION ALL SELECT '2013-04-10', 1
@hafuu
hafuu / ObsoleteAttributeTest
Last active December 30, 2015 03:58
F# 3.1 で ObsoleteAttribute を使うときの注意点? RecordとObsoleteAttributeは相性が悪いようだ。もしRecordをObsoleteにするなら、すべてのフィールドにObsoleteAttributeを付けたほうが良さそう。
module ObsoleteAttributeTest
open System
module Record =
[<Obsolete>]
type Foo = {
A: string
B: int
}
@hafuu
hafuu / gist:8662191
Created January 28, 2014 04:17
数式を展開するマクロ
Sub expandAll()
Dim sw
sw = Timer
Dim ss
Set ss = Sheets
For i = 1 To ss.Count
Dim s
Set s = ss(i)
Dim orig
orig = s.EnableCalculation
@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)
@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 / 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 / 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 / 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 / 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()