Skip to content

Instantly share code, notes, and snippets.

@wafe
wafe / gist:2000145
Created March 8, 2012 10:16
node.js uncaughtException logging using winston
var winston = require('winston'); // https://github.com/flatiron/winston
var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)(),
new (winston.transports.File)({ filename : 'winston.log', timestamp: true, /*maxsize: 2000, maxFiles: 5*/ })
]
});
process.on('uncaughtException', function (err) {
@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 / 0_Readme.md
Last active December 28, 2020 10:25
node.js Buffer 클래스 발표 시 사용한 코드

node.js 스터디에서 Buffer 클래스에 대해 발표할 때 사용한 코드입니다.

발표 내용은 YouTube 에 올렸습니다. (YouTube 동영상 링크)

@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);
}
@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 / 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 / C# php Serializer.cs
Last active July 25, 2016 12:37 — forked from xiangwan/C php Serializer.cs
C# php Serializer
/// <summary>
/// Serializer Class.
/// </summary>
public class PhpSerializer
{
//types:
// N = null
// s = string
// i = int
@wafe
wafe / code.cs
Last active December 29, 2016 14:09
dotnet 4.5 System.Uri Problem
string url1 = "http://localhost/contents/?registered_date_from=2016-12-26T15%3A00%3A00.000Z&registered_date_to=2016-12-27T15%3A00%3A00.000Z&keywords=%EA%B3%84%ED%9A%8D%EC%84%9C";
string url2 = "http://localhost/contents/?registered_date_from=2016-12-26T15%3A00%3A00.000Z&registered_date_to=2016-12-27T15%3A00%3A00.000Z";
var uri1 = new Uri(url1);
var uri2 = new Uri(url2);
Console.WriteLine(uri1.PathAndQuery);
Console.WriteLine(uri2.PathAndQuery);
/* 쿼리 스트링의 구성에 따라서(현상으로는 UTF-8 한글이 인코딩된 쿼리스트링이

Keybase proof

I hereby claim:

  • I am wafe on github.
  • I am heejoonlee (https://keybase.io/heejoonlee) on keybase.
  • I have a public key whose fingerprint is 4FCF EF86 AB85 BD2B 445A 9546 B30B 9758 B00A 0AE2

To claim this, I am signing this object: