Skip to content

Instantly share code, notes, and snippets.

@honda0510
honda0510 / isPrime.hs
Last active December 10, 2015 15:09
【Haskell】素数判定
-- 試し割り
isPrime :: Int -> Bool
isPrime 2 = True
isPrime n
| n < 2 = False
| (n `mod` 2) == 0 = False
| otherwise = testDiv 3 n
where testDiv :: Int -> Int -> Bool
testDiv i n
| i * i > n = True
@honda0510
honda0510 / last.hs
Last active December 10, 2015 14:48
【Haskell】lastを自前で実装
last' :: [a] -> a
last' [] = error "list must be `length list > 0`"
last' [x] = x
last' (x:xs) = last' xs
last'' :: [a] -> a
last'' [] = error "list must be `length list > 0`"
last'' xs = xs !! ((length xs) - 1)
@honda0510
honda0510 / tail.hs
Created January 4, 2013 04:56
【Haskell】tailを自前で実装
tail' :: [a] -> [a]
tail' [] = []
tail' [a] = []
tail' (_:xs) = xs
@honda0510
honda0510 / gist:4306310
Last active December 9, 2015 17:49
VBScript向けにFormat関数を作ってみた。でも、コマンドプロンプトが表示される。
Option Explicit
MsgBox Format(Date, "yyyyMMdd")
Function Format(DateTime, Pattern)
Dim command, wshShell, wshShellStatus, Stream
command = "PowerShell -Command Get-Date """ & DateTime & """ -Format """ & Pattern & """"
Set wshShell = CreateObject("WScript.Shell")
@honda0510
honda0510 / README
Created November 28, 2012 12:08
モーグにログインしてモーグのフリーソフトをダウンロードする例
ポップアップのメニュー選択
http://www.moug.net/faq/viewtopic.php?t=64934
モーグのフリーソフト
http://www.moug.net/cgi-bin/softwaredl.cgi?excel+SI2012111501
@honda0510
honda0510 / gist:4160295
Created November 28, 2012 10:14
POSTしたデータをIEで確認する方法
モーグの詳細検索を例に説明します。
http://www.moug.net/faq/search.php
1. IE9で詳細検索画面を開く。
2. IE9の開発者ツールを開く(F12キー)。
3. [ネットワーク]タブを開く。
4. [キャプチャの開始]ボタンをクリック。
5. 詳細検索画面で適当に検索する。
6. 結果が表示されたら[キャプチャの停止]ボタンをクリック。
7. 開発者ツールに表示されるURLの内、http://www.moug.net/faq/search.php?mode=results をクリック。
@honda0510
honda0510 / gist:4045749
Created November 9, 2012 13:54
Sublime Text 日本語化
https://docs.google.com/open?id=0B_dAu5x064QTWW5TQ2p0NzRPZTQ
https://docs.google.com/open?id=0B_dAu5x064QTZ1lZaXpmS3ZMQ0U
Option Explicit
Sub test()
Const MAX_NUM As Long = 65535
Dim num As Long
Dim row As Long
Dim col As Long
Dim result As Long
Dim table(0 To MAX_NUM, 0 To 15) As Long
@honda0510
honda0510 / Module1.bas
Created October 4, 2012 12:55
UTCをJSTに変換
Option Explicit
Sub test()
Dim WmiDateTime As WmiDateTime
Set WmiDateTime = New WmiDateTime
WmiDateTime.Value = "20121004010446.000000-000"
Debug.Print WmiDateTime.LocalDateTime
' 2012/10/04 10:04:46
@honda0510
honda0510 / code1.bas
Created September 19, 2012 05:23
リダイレクト先のURLを取得 http://www.moug.net/faq/viewtopic.php?t=64316
Option Explicit
' 参照設定
' Microsoft XML, v6.0
Sub test()
Debug.Print getLocation("http://nec.www.yahoo.co.jp")
End Sub
Function getLocation(url As String) As String