Skip to content

Instantly share code, notes, and snippets.

@azechi
azechi / gist:89eebaef73b9ba8e497b
Last active October 13, 2015 07:27
PowerShell よく忘れる
select-object @{ n = "propertyName"; e = { /* expression $_ */ } }
@azechi
azechi / 2003eventlog_clear.ps1
Created February 21, 2013 05:52
windows 2003 のイベントログ ローテーション
# windows 2003 向けのイベントログローテーションタスク
param($logname="[logname]", $backupFolder=(&{Split-Path $MyInvocation.ScriptName}))
$logfiles = Get-WmiObject win32_nteventlogfile -Filter "LogfileName='$logname'" -EnableAllPrivileges
if ($logfiles -eq $null)
{
throw "ログファイル $logname は存在しません。"
}
@azechi
azechi / sampleImage.cs
Created February 21, 2013 07:10
指定した文字を入れた画像ファイルを作る
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
namespace TextImage
{
@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"
@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 / 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 / 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 / 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 / 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'
};
curl http:// -H 'Content-type: application/x-www-form-urlencoded;charset=utf-8' -X POST -d "_method=patch" ...