Skip to content

Instantly share code, notes, and snippets.

HttpContent content;
var context = Request.Properties["MS_HttpContext"] as System.Web.HttpContextWrapper;
if (context != null) {
content = new StreamContent(context.Request.GetBufferlessInputStream(disableMaxRequestLength: true));
content.Headers.ContentType = Request.Content.Headers.ContentType;
} else {
content = Request.Content;
}
await content.ReadAsMultipartAsync(provider);
@azechi
azechi / Startup.cs
Created April 15, 2016 02:29
ASP.NET PreApplicationStartMethod
using System.Web;
[assembly: PreApplicationStartMethod(typeof(Startup), "PreApplicationStart")]
public static class Startup
{
public static void PreApplicationStart()
{
}
@azechi
azechi / triangle.rb
Created July 20, 2015 04:38
三角形の形を求める
class Triangle
def self.hantei(a,b,c)
# 2辺を足した数が残り1辺"より小さい"
if(!(a < b + c && b < a + c && c < a + b))
return '三角形じゃないです><'
end
curl http:// -H 'Content-type: application/x-www-form-urlencoded;charset=utf-8' -X POST -d "_method=patch" ...
@azechi
azechi / base32.cs
Last active August 29, 2015 14:18
work
private static readonly Char[] CHARS = new Char[] {
'a','b','c','d','e',
'f','g','h','i','j',
'k','l','m','n','o',
'p','q','r','s','t',
'u','v','w','x','y',
'z',
'2','3','4','5','6','7'
};
@azechi
azechi / MyCheckbox.cs
Last active August 29, 2015 14:05
CheckBoxControl.InputAttributes
public class MyCheckBox : CheckBox
{
protected override void OnInit(EventArgs e)
{
var _ = this.InputAttributes;
base.OnInit(e);
}
}
@azechi
azechi / module.cpp
Last active August 29, 2015 14:03
IISNativeModule W3C Log CustomField
HRESULT __stdcall RegisterModule(
DWORD dwServerVersion,
IHttpModuleRegistrationInfo* pModuleInfo,
IHttpServer* pGlobalInfo
) {
::OutputDebugString ( TEXT("RegisterModule") );
HRESULT hr = S_OK;
@azechi
azechi / makecert.bat
Created February 22, 2013 07:41
プライベートCA
:: ルートCAを作る
makecert -n "CN=MY CA" -pe -cy authority -r -sv "myca.pvk" "myca.cer"
:: 中間CA
makecert -n "CN=MY 2 CA" -pe -cy authority -iv "myca.pvk" -ic "myca.cer" -sv "my2ca.pvk" "my2ca.cer"
:: 証明書 サーバー : 1.3.6.1.5.5.7.3.1 クライアント : 1.3.6.1.5.5.7.3.2
makecert -n "CN=対象の名前" -pe -eku 1.3.6.1.5.5.7.3.1 -sky exchange -sy 12 -iv "ca.pvk" -ic "ca.cer" -sv "my.pvk" "my.cer"
:: 作った証明書と秘密鍵は pvk2pfx.exe を使ってインストール用ファイルにする
@azechi
azechi / clear_froz.ps1
Created February 21, 2013 09:06
Xmailの凍結メッセージ処理
function func()
{
param ( $msgfile, [int]$lev0, [int]$lev1, [string] $from, [string]$to, [datetime] $date)
$base = $spool | Join-Path -ChildPath $lev0 | Join-Path -ChildPath $lev1
# メッセージ
$base | Join-Path -ChildPath "froz" | Join-Path -ChildPath $msgfile | Copy-Item
# ログ
$base | Join-Path -ChildPath "slog" | Join-Path -ChildPath $msgfile | Copy-Item -Destination "$msgfile.log"
@azechi
azechi / gist:fd665f38d647975cb91b
Last active December 14, 2015 00:59
WCFクライアントコード生成
:: v3.5のwcfクライアントコードを生成する
:: レジストリを検索して %windowsSdkDir% を設定
call "%VS100COMNTOOLS%VCVarsQueryRegistry.bat" 32bit No64bit
call set path=%windowsSdkDir%bin\NETFX 4.0 Tools;%windowsSdkDir%bin;%path%
:: ※HogeServiceフォルダには余分なファイルが無いこととする
:: ※サービス定義の既定の名前空間を Fuga.Piyo に変換する
svcutil /t:code "$(SolutionDir)etc\ServiceReference\HogeService\*.*" /async /noConfig /targetClientVersion:Version35 /namespace:http://tempuri.org/,Fuga.Piyo /out:HogeServiceProxy.cs /directory:"$(ProjectDir)ServiceProxy"