Skip to content

Instantly share code, notes, and snippets.

@wafe
wafe / InitLogMethod.cs
Last active April 22, 2016 03:37
log4net 로그 XML 읽어서 초기화하는 예시
void InitLog(string log4netConfigXmlPath, string logFilePath)
{
XmlDocument doc = new XmlDocument();
doc.Load(log4netConfigXmlPath);
// log4net 설정 XML 에서 "FileLog" 라는 이름의 appender 를 찾아서 설정으로 받은
// 로그 파일 경로를 변경해준다. log4net 설정 XML을 만들 때 주의.
XmlAttribute filePathAttr = (XmlAttribute)doc.SelectSingleNode("/log4net/appender[@name='FileLog']/file/@value");
filePathAttr.Value = logFilePath;
@wafe
wafe / ShuffleArray.cs
Created December 2, 2012 02:48
Shuffling Array of FileInfo
static FileInfo[] ShuffleArray (FileInfo[] src)
{
FileInfo[] result = new FileInfo[src.Length];
Random ran = new Random ();
List<KeyValuePair<int, FileInfo>> list = new List<KeyValuePair<int, FileInfo>> (src.Length);
foreach (var fi in src)
{
list.Add (new KeyValuePair<int, FileInfo> (ran.Next (), fi));
}
@wafe
wafe / gist:0e13c84487094ead3b60
Created July 10, 2015 12:14
php not defined exception class
<?php
try
{
throw new Exception('an exception');
}
catch (NotDefinedExceptionClass $eae)
{
echo $eae->getMessage();
}
@wafe
wafe / VthreeModule.cs
Created January 8, 2015 01:02
Simple Nancy Module OnError Json Response Example
public abstract class VthreeModule : NancyModule
{
static ILog LOGGER;
static VthreeModule()
{
LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
}