Skip to content

Instantly share code, notes, and snippets.

@jsakamoto
jsakamoto / App.razor
Created December 18, 2019 11:35
Blazor で、行が動的に増減する入力フォームを実装してみる
<div>
@foreach (var person in this.People)
{
<div @key="person.Id">
<input type="text" placeholder="名前" @bind="person.Name" />
<input type="number" placeholder="年齢" @bind="person.Age" />
<button @onclick="()=>OnClickRemove(person)">削除</button>
</div>
}
</div>
@jsakamoto
jsakamoto / sample.cs
Created September 27, 2012 08:17
return result as PartialViewResult, and translation from PartialViewResult to string.
public ViewResultBase Render(HtmlHelper helper)
{
return new PartialViewResult
{
ViewName = "AnyPartialViewResult",
ViewData = new ViewDataDictionary(helper.ViewData)
{
Model = new AnyPartialViewModel()
},
TempData = helper.ViewContext.TempData
@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) =
<p>
<div>
<input type="text" @bind="Text1" />
Text1: [@Text1]
</div>
</p>
<p>
<div>
<input type="text" @bind="Text2" @bind:event="oninput" />
@jsakamoto
jsakamoto / Person.cs
Last active July 26, 2020 11:30
Study of System.Text.Json
namespace StudyOfSystemTextJson
{
public class Person
{
public string Name { get; }
public int Age { get; }
public Person(string name, int age)
{
@jsakamoto
jsakamoto / - README -.md
Last active July 25, 2020 09:29
Wrapper class for System.Text.Encoding object to add missing "BodyName" and "HeaderName" property.

What's this?

This is C# code for .NET Core application.

This code provides BodyNamePatchedEncoding Encoding class for wrapping other encoding object to avoid raising "System.NotSupportedException : No data is available for encoding ????".

This exception is sometimes raised when using the encoding object that is in System.Text.Encoding.CodePages NuGet package, because those encoding classes don't implement "BodyName" and "HeaderName" property.

@jsakamoto
jsakamoto / counter.component.ts
Created January 26, 2019 01:33
Angular + SignalR な Web アプリで、HubConnection.invoke() 時の変更検知発動を抑止する
import { Component, NgZone, OnInit, OnDestroy } from '@angular/core';
import { HubConnectionBuilder, HubConnection, LogLevel, JsonHubProtocol } from '@aspnet/signalr';
import { Subject } from 'rxjs/Subject';
import { Subscription } from 'rxjs/Subscription';
@Component({
selector: 'app-counter-component',
templateUrl: './counter.component.html'
})
export class CounterComponent implements OnInit, OnDestroy {
@jsakamoto
jsakamoto / _README.md
Last active November 18, 2018 04:15
Jasmine による TypeScript/JavaScript 単体テストを実行する環境を作る - karma 編

基本ステップ

OS 環境の整備

  1. node.js をインストールしておく (Windows ならここからインストーラをダウンロード)

プロジェクトごとの環境構築

  1. 作業フォルダ(プロジェクトフォルダ)に移動。
  2. &gt; npm init で作業場所を準備、package.json を生成。
@jsakamoto
jsakamoto / README.md
Last active July 9, 2018 13:01
How to enable MFA on your AWS account

How to enable MFA on your AWS account

@jsakamoto
jsakamoto / Test-MixedContent.ps1
Created June 13, 2018 23:01 — forked from stknohg/Test-MixedContent.ps1
Selenium WebDriver(Chrome)を使った簡単なMixed Contentのチェック例
# パスチェック
# カレントディレクトリにWebDriver.dllとchromedriver.exeがある前提
if ( -not (Test-Path -LiteralPath '.\WebDriver.dll')) {
Write-Error 'WebDriver.dllがありません。'
return
}
if ( -not (Test-Path -LiteralPath '.\chromedriver.exe')) {
Write-Error 'chromedriver.exeがありません。'
return
}