This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Console.WriteLine("Hello, World."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GDataDB を NuGet Package Manager を使ってプロジェクトに追加しておくこと。 | |
[HttpPost] | |
public ActionResult Index(Attendee attendee) | |
{ | |
// ここでスプレッドシートへ書き込み | |
var gdbclient = new GDataDB.DatabaseClient("(user name)", "(password)"); | |
var db = gdbclient.GetDatabase("Attendees"); | |
var tbl = db.GetTable<Attendee>("Sheet1"); | |
tbl.Add(attendee); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec numofbits bitwidth x = | |
match bitwidth with | |
|0 -> 0 | |
|_ -> (x &&& 1) + numofbits (bitwidth - 1) (x / 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://atnd0.apphb.com/api/attendees | |
public class Attendee | |
{ | |
public int AttendeeID { get; set; } | |
[Required, MaxLength(20)] | |
public string Name { get; set; } | |
[Required, MaxLength(20)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOTICE: | |
// This is "concept" sample code. | |
// Not enough resouce disposing, etc. | |
public class MyRemoteAttribute : RemoteAttribute | |
{ | |
public RemotableCustomAttribute(string action, string controller) : base(action, controller) | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System;; | |
open System.IO;; | |
let dir = @"c:\workdir";; | |
Directory.GetFiles(dir) | |
|> Seq.map (fun x-> (x, x.Replace("original", "replaced"))) | |
|> Seq.iter (fun (x,y) -> File.Move(x, y));; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System;; | |
open System.IO;; | |
open System.Text;; | |
open System.Text.RegularExpressions;; | |
let dir = @"c:\workdir";; | |
Directory.GetFiles(dir, "*.udl") | |
|> Seq.map (fun x-> (x, File.ReadAllText(x))) | |
|> Seq.map (fun(x,y)->(x, Regex.Replace(y,"Data Source=[^;]+",@"Data Source=.\SQLEXPRESS"))) | |
|> Seq.iter (fun (x,y) -> File.WriteAllText(x,y,Encoding.Unicode));; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Configuration; | |
using Newtonsoft.Json; | |
using Twitterizer; | |
public class Bot | |
{ | |
public static void Tweet() | |
{ | |
// Need appSettings section in .config: | |
// <add key="key" value="{ConsumerKey:'...', ConsumerSecret:'...', AccessToken:'...', AccessTokenSecret:'...'}" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.IO | |
open System.Linq | |
let dir = new DirectoryInfo("c:\\") | |
let fileOfFoo = dir.GetFiles().FirstOrDefault(fun f -> f.Name = "foo") | |
printfn "%s" (if fileOfFoo = null then "null!" else "exists!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.IO | |
open System.Linq | |
type MyFile = {Name:string; Size:int64} | |
let toMyFile (f:FileInfo) = {Name=f.Name; Size=f.Length} | |
let dir = new DirectoryInfo("c:\\") | |
let fileOfFoo = | |
dir.GetFiles() | |
|> Array.map toMyFile |
OlderNewer