Skip to content

Instantly share code, notes, and snippets.

<style>
#tell-me-wys-link {
position:fixed;
bottom:0;
right:-16.9em;
background-color: #fff;
border: solid 1px #ccc;
color:#444;
padding: 4px;
opacity:0.7;
@jsakamoto
jsakamoto / EmbeddedResourceFileSystem2.cs
Created May 31, 2014 11:56
EmbeddedResourceFileSystem2.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Microsoft.Owin.FileSystems;
public class EmbeddedResourceFileSystem2 : IFileSystem
{
protected readonly EmbeddedResourceFileSystem _fileSystem;
@jsakamoto
jsakamoto / xml.xml
Created June 23, 2014 05:24
How to enable Intelli Sense of .xml file by XSD on Visual Studio?
<?xml version="1.0" encoding="utf-16"?>
<root
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="full/path/of/.xsd">
</root>
@jsakamoto
jsakamoto / HomeController.cs
Created June 18, 2015 14:01
How to turn on/off on Raspberry Pi GPIO port 25 by ASP.NET MVC action method.
// use TinyGPIO.cs
// https://github.com/sample-by-jsakamoto/SignalR-on-RaspberryPi/blob/master/myapp/TinyGPIO.cs
using myapp;
using System.Web.Mvc;
public class HomeController : Controller
{
[HttpPut]
public ActionResult TurnOnLED()
{
@jsakamoto
jsakamoto / gist:1985918
Created March 6, 2012 12:16
gist にデビュー。
Console.WriteLine("Hello, World.");
@jsakamoto
jsakamoto / gist:2011416
Created March 10, 2012 13:25
GDataDB を使って、ASP.NET MVC3 アプリから Google Docs スプレッドシートへ書き込みを行う
// 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);
@jsakamoto
jsakamoto / gist:2204346
Created March 26, 2012 10:28
count number of bits that type is integer. (by F#)
let rec numofbits bitwidth x =
match bitwidth with
|0 -> 0
|_ -> (x &&& 1) + numofbits (bitwidth - 1) (x / 2)
@jsakamoto
jsakamoto / summary.cs
Created April 3, 2012 14:19
sammary of CLRH Extra session-1 sample code.
// 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)]
@jsakamoto
jsakamoto / MyRemoteAttribute.cs
Created April 14, 2012 01:30
ASP.NET MVC Data Annotation Valiteion - Remote Validation with Server Side Validation!
// NOTICE:
// This is "concept" sample code.
// Not enough resouce disposing, etc.
public class MyRemoteAttribute : RemoteAttribute
{
public RemotableCustomAttribute(string action, string controller) : base(action, controller)
{
}
@jsakamoto
jsakamoto / gist:3009448
Created June 28, 2012 06:12
rename all files by F#
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));;