Skip to content

Instantly share code, notes, and snippets.

@myaumyau
myaumyau / GoogleChromeMemo.md
Last active January 31, 2023 22:22
[md]Google Chrome Memo
@myaumyau
myaumyau / CreateHttpContext.cs
Created February 18, 2013 03:49
[C#]HttpContext生成
using (MemoryStream stream = new MemoryStream())
{
using (StreamWriter writer = new StreamWriter(stream))
{
SimpleWorkerRequest workerRequest = new SimpleWorkerRequest(
"/", Path.GetTempPath(), "/index.aspx", "", writer);
HttpContext httpContext = new HttpContext(workerRequest);
HttpContext.Current = httpContext;
}
}
@myaumyau
myaumyau / GenericCollectionBase.cs
Created February 18, 2013 03:50
[C#]型指定されたコレクションの基本機能を提供します。
using System;
using System.Collections;
using System.Collections.Generic;
namespace Myaumyau.Collections
{
/// <summary>
/// 型指定されたコレクションの基本機能を提供します。
/// </summary>
/// <typeparam name="T">要素の型。</typeparam>
@myaumyau
myaumyau / CreateFolder.vbs
Created February 18, 2013 03:52
[vbs]指定されたパスのフォルダを再帰作成
Option Explicit
If WScript.Arguments.Count = 3 Then
Call CreateFolder(WScript.Arguments.Item(0))
End If
Sub CreateFolder(strPath)
Dim objFso
Dim strParentPath
Set objFso = CreateObject("Scripting.FileSystemObject")
@myaumyau
myaumyau / NumRefToString.js
Created February 18, 2013 03:55
[js]数値文字参照(16進数, 10進数)を文字列に変換
function hexNumRefToString(hexNumRef) {
return hexNumRef.replace(/&#x([0-9a-f]+);/ig, function(match, $1, idx, all) {
return String.fromCharCode('0x' + $1);
});
}
function decNumRefToString(decNumRef) {
return decNumRef.replace(/&#(\d+);/ig, function(match, $1, idx, all) {
return String.fromCharCode($1);
});
}
@myaumyau
myaumyau / Construct.cs
Created February 18, 2013 03:57
[C#]引数付きコンストラクタのインスタンスをgenericで生成
public static T Construct<T, A>(A arg)
{
Type type = typeof(T);
ConstructorInfo ctor = type.GetConstructor(new Type[] { typeof(A) });
if (ctor == null)
throw new NotSupportedException("コンストラクタが定義されていません。");
return (T)ctor.Invoke(new object[] { arg });
}
@myaumyau
myaumyau / PermutationAndCombination.js
Created February 18, 2013 04:01
[js]Combinations And Permutations(組合せと順列)
// http://d.hatena.ne.jp/zecl/20090127/p1
/** 組み合わせ */
var Combinations = (function() {
var _public,
_items = null,
_length = 0,
_indices = null,
_combinations = null,
_finalIndices = null,
@myaumyau
myaumyau / Calendar.js
Created February 18, 2013 04:02
[js]自前カレンダー
Calendar = function() {
this.initialize.apply(this, arguments);
}
Calendar.config = {
tags: {
header: "table",
headerChild: "tr",
thisMonth: "td",
prev: "td",
next: "td",
@myaumyau
myaumyau / Stopwatch.js
Created February 18, 2013 04:03
[js]Stopwatch
var Stopwatch = function() {
this.initialize.apply(this, arguments);
};
Stopwatch.prototype = {
initialize: function() {
this.reset();
},
start: function() {
this.startTime = new Date();
},
@myaumyau
myaumyau / ConfigOverrideTest.cs
Created February 18, 2013 04:04
[C#]ConfigurationManager.AppSettingsの値を書き換え
/*
* ConfigurationManager.AppSettingsの値を書き換え
* http://stackoverflow.com/questions/158783/is-there-a-way-to-override-configurationmanager-appsettings
*/
using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Configuration.Internal;
using System.Reflection;