Skip to content

Instantly share code, notes, and snippets.

View nakamura-to's full-sized avatar

Toshihiro Nakamura nakamura-to

View GitHub Profile
@nakamura-to
nakamura-to / Dept.java
Created October 24, 2012 12:02
An Embedded Value implementation in Doma
import org.seasar.doma.Entity;
import org.seasar.doma.Id;
@Entity
public class Dept {
@Id
private Integer id;
private String name;
@nakamura-to
nakamura-to / Client.js
Created October 31, 2012 11:36
Concept code of WinJS.xhr Wrapper
var xhr = new Xhr({
baseUrl: 'http://localhost:8080/api',
user: "",
password: "",
type: 'json',
preHandler: function () {},
postHandler: function () {},
errorHandler, function () {}
headers: {},
data: {},
@nakamura-to
nakamura-to / WebApiConfig.cs
Created November 7, 2012 05:27
ModelMetadata.ConvertEmptyStringToNull in ASP.NET Web API
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
@nakamura-to
nakamura-to / gist:4159599
Created November 28, 2012 07:22
raw notification sample
using System.Diagnostics;
using System.IO;
using System.Text;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
// see http://msdn.microsoft.com/library/windows/apps/hh761488.aspx
@nakamura-to
nakamura-to / gist:4244539
Created December 9, 2012 11:57
Close all OracleParameters in Soma
member this.SetupCommand (ps:PreparedStatement) (command:DbCommand) =
command.CommandText <- ps.Text
let dbParams =
ps.Parameters
|> List.map (fun param ->
let dbParam = command.CreateParameter()
dialect.SetupDbParameter(param, dbParam)
dbParam )
|> List.toArray
command.Parameters.AddRange(dbParams)
@nakamura-to
nakamura-to / gist:4316660
Created December 17, 2012 08:29
ASP.NET Web API Test in F#
open System
open System.Collections.Generic
open System.Net
open System.Net.Http
open System.Web.Http
open System.Web.Http.Dispatcher
open System.Web.Http.SelfHost
open Microsoft.VisualStudio.TestTools.UnitTesting
open Newtonsoft.Json.Linq
open Newtonsoft.Json.Serialization
@nakamura-to
nakamura-to / gist:4343626
Created December 20, 2012 07:52
Intercepting the Backbone.View initialize method.
var _View = Backbone.View;
Backbone.View = function () {
logger.info('before');
var init = this.initialize;
if (init) {
this.initialize = function () {
logger.info('before initialize');
init.call(this);
logger.info('after initialize');
}.bind(this);
@nakamura-to
nakamura-to / DeleteDelegate.java
Created December 21, 2012 21:05
Doma 改善案。 汎用的なDelegateで論理削除。
package tutorial.dao;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import org.seasar.doma.jdbc.Config;
public class DeleteDelegate {
protected final Config config;
@nakamura-to
nakamura-to / gist:4483335
Created January 8, 2013 12:25
チューリングを読む p.126
// .01010101...
type Symbol =
| None
| Str of string
| Num of int
type Op =
| P of Symbol
| R
@nakamura-to
nakamura-to / gist:4483347
Last active December 10, 2015 19:48
チューリングを読む p.129
// .01000000...
type Symbol =
| None
| Str of string
| Num of int
type Op =
| P of Symbol
| R