Skip to content

Instantly share code, notes, and snippets.

View kowill's full-sized avatar

kowill kowill

  • 03:46 (UTC +09:00)
View GitHub Profile
using System;
namespace Test
{
public class Program
{
public static void Main()
{
Console.WriteLine("Hello, world!");
}
@kowill
kowill / SampleProxy.cs
Created December 2, 2014 15:02
使い道があまり思いつかないけども作成。
public class Sample : ISample
{
public Sample() { }
public Sample(string str)
{
this.StringProperty = str;
}
public string StringProperty { get; set; }
public void CallMethod()
@kowill
kowill / ExecPs.cmd
Created December 3, 2014 00:04
制限環境下で一時的にps実行。
@echo off
setlocal
set ExePolicy=RemoteSigned
for /f "usebackq tokens=*" %%i in (`powershell.exe -Command "Get-ExecutionPolicy"`) do @set Result=%%i
echo ExecutionPolicyは%Result%です。
powershell Set-ExecutionPolicy %ExePolicy%
echo ExcutionPolicyを%ExePolicy%に変更しました。
@kowill
kowill / gist:0933d3784a77a306fae0
Created January 4, 2015 16:52
XElement内の指定した場所にある値を取得する。ただし、複数項目持つ場合はだめ。
public static class XElementExtensions
{
public static string GetSingleElementValue(this XElement element, params XName[] names)
{
if (names.Length < 1)
{
return string.Empty;
}
if (names.Length == 1)
{
@kowill
kowill / FirebirdSample1.cs
Last active August 29, 2015 14:13
FIrebirdのテーブル一覧取得。fbembed.dllの配置とFirebirdSql.Data.FirebirdClient.dllの参照を忘れずに。
using System.Data;
using FirebirdSql.Data.FirebirdClient;
namespace FirebirdTest
{
class Program
{
static void Main(string[] args)
{
var connectionBuilder = new FbConnectionStringBuilder();
@kowill
kowill / gist:58ccca7cb4244924851a
Created January 17, 2015 14:21
書き殴り。MSDN見たほうが良いと思うw
/// <summary>
/// IISUtility
/// </summary>
public class IisUtility
{
/// <summary>
/// IISへのSite登録
/// </summary>
/// <param name="inf"></param>
/// <returns></returns>
@kowill
kowill / shutdown
Created January 23, 2015 09:08
シャットダウン時に無駄なメッセージ using Microsoft.Win32;
public Form1() {
InitializeComponent();
SessionEndingEventHandler sessionEndHandler = (sender, e) => {
if (e.Reason == SessionEndReasons.SystemShutdown) {
if (MessageBox.Show("シャットダウンしようとしています。\n\n本当にいいですか?", "質問", MessageBoxButtons.YesNo) == DialogResult.Yes) {
e.Cancel = true;
}
}
};
SystemEvents.SessionEnding += sessionEndHandler;
@kowill
kowill / gist:7abe6642d57cecb052a2
Created June 4, 2015 15:46
ポートセービングIPマスカレードを切る。
#nat descriptor backward-compatibility 1
#save
#restart
$path = "HKLM:\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters";
Set-ItemProperty -path $path -name "LayerDriver JPN" -type string -value "kbd106.dll"
Set-ItemProperty -path $path -name "OverrideKeyboardIdentifier" -type string -value "PCAT_106KEY"
Set-ItemProperty -path $path -name "OverrideKeyboardSubtype" -type DWord -value 2
Set-ItemProperty -path $path -name "OverrideKeyboardType" -type DWord -value 7
Get-ItemProperty $path
@kowill
kowill / IisSettings-Pattern1.ps1
Last active August 29, 2015 14:24
IISの設定
dism /online /enable-feature `
/featurename:IIS-WebServerRole `
/featurename:IIS-WebServer `
/featurename:IIS-CommonHttpFeatures `
/featurename:IIS-StaticContent `
/featurename:IIS-DefaultDocument `
/featurename:IIS-DirectoryBrowsing `
/featurename:IIS-HttpErrors `
/featurename:IIS-HttpRedirect `
/featurename:IIS-ApplicationDevelopment `