Skip to content

Instantly share code, notes, and snippets.

@jsakamoto
jsakamoto / code2013-kingyobachi-banner.html
Created June 26, 2013 12:32
Code 2013 きんぎょばち ~ teach me / teach you ~ テーマ募集バナー
<a id="code2013-kingyobachi-banner" href="http://codejapan.jp/2013/kingyobachi" target="_blank" style="display:inline-block">
<img src="http://codejapan.jp/images/code2013/info-kingyobachi.jpg" title="きんぎょばち ~ teach me / teach you ~ テーマ募集中!!" style="border:none"/>
</a>
@jsakamoto
jsakamoto / httpd.fsx
Created May 17, 2013 03:30
Small http daemon by F# script. run "> fsi.exe httpd.fsx", then you can access http://localhost:8080/anycontents
open System
open System.IO
open System.Net
let root = @"c:\inetpub\wwwroot"
let listener = new HttpListener()
listener.Prefixes.Add "http://*:8080/"
listener.Start ()
let rec procreq ():(unit->unit) =
@jsakamoto
jsakamoto / x.cs
Last active December 17, 2015 01:59
if (args.Length == 2 && args[1] == "-f")
{
sha1(File.ReadAllBytes(args[2]));
}
else if (args.Length == 1)
{
sha1(Encoding.ASCII.GetBytes(args[1]));
}
else if (args.Length == 0)
{
@jsakamoto
jsakamoto / Script1.fsx
Created March 5, 2013 15:03
Setup holidays of .gan file.
// download from http://sourceforge.net/projects/dday-ical/files/
//#r @"DDay.Collections.dll"
#r "DDay.iCal.dll"
#r "System.Xml.Linq"
open System
open System.IO
open System.Linq
open System.Xml
open System.Xml.Linq
open DDay.iCal
@jsakamoto
jsakamoto / Script1.fsx
Created March 4, 2013 03:59
How to retrieve Japanese Holidays from Apple web site with DDay.ICal library by F# Script.
// download from http://sourceforge.net/projects/dday-ical/files/
#r @"DDay.Collections.dll"
#r @"DDay.iCal.dll"
open DDay.iCal
open System
open System.Linq
new Uri("http://ical.mac.com/ical/Japanese32Holidays.ics")
|> iCalendar.LoadFromUri
|> Seq.collect (fun x -> x.Events)
@jsakamoto
jsakamoto / Program.cs
Created March 4, 2013 01:38
How to retrieve Japanese Holidays from Apple web site with DDay.ICal library.
using DDay.iCal;
using System;
using System.Linq;
// PM> Install-Package DDay.iCal
class Program
{
static void Main(string[] args)
{
var cals = iCalendar.LoadFromUri(new Uri("http://ical.mac.com/ical/Japanese32Holidays.ics"));
@jsakamoto
jsakamoto / Index.cs
Last active December 12, 2015 02:18
@{
var comics = new[] {
new {Title = "Groo", Publisher = "Dark Horse Comics"},
new {Title = "Spiderman", Publisher = "Marvel"}
};
}
<h1>Normal</h1>
<table border="1">
#r "System.Xml.Linq"
open System
open System.Xml
open System.Xml.Linq
open System.IO
if fsi.CommandLineArgs.Length < 2 then
raise <| new Exception("error: .gan file name not specified.")
let Element name (xelem:XElement) = xelem.Element(XName.Get(name))
@jsakamoto
jsakamoto / UnitTest1.cs
Created November 1, 2012 12:45
How to write unit test code more simply.
// PM> Install-Package ChainingAssertion
// http://nuget.org/packages/ChainingAssertion
// http://chainingassertion.codeplex.com/
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
public class DateHelper
{
public static DateTime? ToNullableDate(string input)
@jsakamoto
jsakamoto / Global.asax.cs
Created October 10, 2012 00:48
Respond Real HTTP status code in custome error page
using System;
using System.Configuration;
using System.Web;
using System.Web.Configuration;
public class MvcApplication : System.Web.HttpApplication
{
public override void Init()
{
base.Init();