Author: allen
C#: Split a Distinguished Name of Active Directory into array of string
class DistinguishedNameSplit { static string[] hexCodes = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "A", "b", "B", "c", "C", "d", "D", "e", "E", "f", "F" }; public static List<string> Split(string distinguishedName) { List<string> pool = new List<string>(); StringBuilder working = new StringBuilder(); string hexHigh = ""; MachineStatus status = MachineStatus.A; int index = 0; int indexMax = distinguishedName.Length - 1; while (index <= indexMax) { string value = distinguishedName.Substring(index, 1); switch (status) { case MachineStatus.A: if (value == ",") { pool.Add(working.ToString()); working.Clear(); } else if (value == "\"") { working.Append("\""); status = MachineStatus.B; } else if (value == "\\") { status = MachineStatus.C; } else { working.Append(value); } break; case MachineStatus.B: if (value == "\"") { working.Append("\""); status = MachineStatus.A; } else if (value == "\\") { status = MachineStatus.E; } else { working.Append(value); } break; case MachineStatus.C: if (value == "," || value == "\"" || value == "\\") { working.Append(value); status = MachineStatus.A; } else if (hexCodes.Contains(value)) { hexHigh = value; status = MachineStatus.D; } else { throw new ArgumentException("The distinguished name specified is not typed legally."); } break; case MachineStatus.D: if (hexCodes.Contains(value)) { working.Append((char)Convert.ToByte(String.Format("{0}{1}", hexHigh, value), 16)); status = MachineStatus.A; } else { throw new ArgumentException("The distinguished name specified is not typed legally."); } break; case MachineStatus.E: if (value == "," || value == "\"" || value == "\\") { working.Append(value); status = MachineStatus.B; } else if (hexCodes.Contains(value)) { hexHigh = value; status = MachineStatus.F; } else { throw new ArgumentException("The distinguished name specified is not typed legally."); } break; case MachineStatus.F: if (hexCodes.Contains(value)) { working.Append((char)Convert.ToByte(String.Format("{0}{1}", hexHigh, value), 16)); status = MachineStatus.B; } else { throw new ArgumentException("The distinguished name specified is not typed legally."); } break; } index++; } if (status == MachineStatus.A) { pool.Add(working.ToString()); return pool; } else { throw new ArgumentException("The distinguished name specified is not ended correctly."); } } enum MachineStatus { A, B, C, D, E, F } }
关于12个球中称重找出不同者的解答
题目:有12个球,外观完全相同,其中11个球重量相同,另一个重量不同。使用天平称3次,将重量不同的球找出,且需要判断球的轻重。
解答:为了简易,将12个球编为1-12号。
- 第一次称重:左侧1、2、3、4号,右侧5、6、7、8
- 第一次称重如果平衡:说明1-8均为一般球,9-12中包含特殊球。
- 第二次称重:左侧1、11,右侧9、10
- 第二次称重如果平衡:说明除了1-8外,9、10、11也为一般球,推定12为特殊球。
- 第三次称重:左侧1,右侧12
- 第三次称重不可能平衡。
- 第三次称重如果左侧重:12为轻球。
- 第三次称重如果右侧重:12为重球。
- 第二次称重如果左侧重:说明11为重球或9、10中包含轻球。
- 第三次称重:左侧9,右侧10
- 第三次称重如果平衡:11为重球。
- 第三次称重如果左侧重:10为轻球。
- 第三次称重如果右侧重:9为轻球。
- 第二次称重如果右侧重:说明11为轻球或9、10中包含重球。
- 第三次称重:左侧9,右侧10
- 第三次称重如果平衡:11为轻球。
- 第三次称重如果左侧重:9为重球。
- 第三次称重如果右侧重:10为重球。
- 第一次称重如果左侧重:说明1-4中包含重球或5-8中包含轻球。
- 第二次称重:左侧1、2、5,右侧3、4、6
- 第二次称重如果平衡:说明7、8中包含轻球。
- 第三次称重:左侧7、右侧8
- 第三次称重不可能平衡。
- 第三次称重如果左侧重:8为轻球。
- 第三次称重如果右侧重:7为轻球。
- 第二次称重如果左侧重:1、2中包含重球或6为轻球。
- 第三次称重:左侧1、右侧2
- 第三次称重如果平衡:6为轻球。
- 第三次称重如果左侧重:1为重球。
- 第三次称重如果右侧重:2为重球。
- 第二次称重如果右侧重:3、4中包含重球或5为轻球。
- 第三次称重:左侧3、右侧4
- 第三次称重如果平衡:5为轻球。
- 第三次称重如果左侧重:3为重球。
- 第三次称重如果右侧重:4为重球。
- 第一次称重如果右侧重:说明1-4中包含轻球或5-8中包含重球。
- 第二次称重:左侧1、2、5,右侧3、4、6
- 第二次称重如果平衡:说明7、8中包含重球。
- 第三次称重:左侧7、右侧8
- 第三次称重不可能平衡。
- 第三次称重如果左侧重:7为重球。
- 第三次称重如果右侧重:8为重球。
- 第二次称重如果左侧重:3、4中包含轻球或5为重球。
- 第三次称重:左侧3、右侧4
- 第三次称重如果平衡:5为重球。
- 第三次称重如果左侧重:4为轻球。
- 第三次称重如果右侧重:3为轻球。
- 第二次称重如果右侧重:1、2中包含轻球或6为重球。
- 第三次称重:左侧1、右侧2
- 第三次称重如果平衡:6为重球。
- 第三次称重如果左侧重:2为轻球。
- 第三次称重如果右侧重:1为轻球。
- 第三次称重:左侧1、右侧2
- 第三次称重:左侧3、右侧4
- 第三次称重:左侧7、右侧8
- 第二次称重如果平衡:说明7、8中包含重球。
- 第二次称重:左侧1、2、5,右侧3、4、6
- 第三次称重:左侧3、右侧4
- 第三次称重:左侧1、右侧2
- 第三次称重:左侧7、右侧8
- 第二次称重如果平衡:说明7、8中包含轻球。
- 第二次称重:左侧1、2、5,右侧3、4、6
- 第三次称重:左侧9,右侧10
- 第三次称重:左侧9,右侧10
- 第三次称重:左侧1,右侧12
- 第二次称重如果平衡:说明除了1-8外,9、10、11也为一般球,推定12为特殊球。
- 第二次称重:左侧1、11,右侧9、10
- 第一次称重如果平衡:说明1-8均为一般球,9-12中包含特殊球。
朋友的WOW被停權
摘要:我一個朋友因為在AH賣的東西,被別玩家用黑G買走,而被永久停權。剛與GM聊天過,確定為:只要對方是黑G,你收到就會被停權,而不論你是AH、交易、還是郵件。希望各位朋友收錢謹慎。
原因:她在AH放了一件幻化用的衣服,10萬G,被人買走後,遭停權。申訴不處理。因此我代為於遊戲詢問GM。
以下是GM對白:
[04/04/2012]
10:36 [艾可米安娜]: 親愛的玩家您好,請問您今日有遇到什麼遊戲上的問題,需要【GM】艾可米安娜為您服務的嗎?^_^
10:37 [夏目玲子]: 安安。其實不是我的問題,是我朋友的啦
10:37 [夏目玲子]: 他在AH賣了一件衣服,就被永久停權了= =
10:37 [艾可米安娜]: 您好,您的問題是拍賣場所獲得金額是否安全嗎?
10:37 [夏目玲子]: 嗯嗯。
10:38 [夏目玲子]: 電話聯繫GM的時候,GM說是不論哪裡交易,只要對方是黑G就要停權。
10:39 [艾可米安娜]: 建議您販售物品的時候,使用市場價格販售會比較安全喔。
10:39 [夏目玲子]: 喔喔,賣太貴不好是吧= =
10:39 [夏目玲子]: GM還是出個公告吧。。。。AH這種很貴的玩具還是蠻多的,比如坐騎,寵物。
10:40 [夏目玲子]: 因為是難以獲得,“市價”沒辦法看到的
10:40 [艾可米安娜]: 確實,但是市場價格不是gm定義,而是此伺服器去決定的。
10:40 [艾可米安娜]: 不過寒冬長袍賣到10萬金,真的多出很多喔。
10:41 [夏目玲子]: 是呀,那麼我們怎麼知道對方是不是黑G喔= =
10:41 [夏目玲子]: 一個海馬坐騎也能賣上16萬呀
10:42 [艾可米安娜]: gm也無法查詢對方是否使用黑金,僅能建議玩家買/賣物品請使用市場價格,並且禁止在遊戲中涉及現實中交易,避免有收到黑金的可能。
10:43 [夏目玲子]: 唉,因為有可能是黑G,所以就要永久停權了是吧。。。
10:43 [夏目玲子]: 那如果我在AH買一個海馬,再舉報賣家,是不是也可以停權對方?
10:44 [艾可米安娜]: 您可以進行舉報,但也要轉由相關單位查詢是否屬時喔。
10:44 [夏目玲子]: 嗯,問題是相關單位不給查
10:44 [艾可米安娜]: 會的,只要有玩家舉報,gm都會轉由相關單位進行查緝。
10:45 [夏目玲子]: 如果買家是黑G,不論對方是否知情,都會被永久停權嗎?
10:45 [艾可米安娜]: 這個就要看當時的查詢結果了。
10:46 [夏目玲子]: @@ 查詢結果是,我朋友沒在線。。。
10:46 [艾可米安娜]: 請問是您朋友沒有在線,然後與其他人交易黑金嗎?
10:46 [夏目玲子]: 沒有在線,只是AH交易
10:47 [夏目玲子]: 第二天就上不來了
10:47 [艾可米安娜]: 請問您朋友是販售還是購買呢?
10:47 [夏目玲子]: 販售
10:47 [艾可米安娜]: 請問是自己販售的嗎?
10:47 [夏目玲子]: 大概是吧,他也不確定
10:48 [艾可米安娜]: 若您朋友覺得不是他自己販售的,可以請本人使用客服支援申告被盜案件查詢喔。
10:48 [夏目玲子]: 查詢過了。。。。GM說沒有異常登陸
10:48 [艾可米安娜]: 那….就真的沒有辦法了。
10:48 [夏目玲子]: 但是是黑G交易。。。又不給證明
10:49 [艾可米安娜]: 因為查詢的資訊屬內部資訊,是不對外公布的。
10:49 [夏目玲子]: 是呀,可是我朋友在其他伺服器也賣同樣價格,都沒發現問題啊= =
10:50 [艾可米安娜]: 那表示所獲得金額沒有異常喔。
10:50 [夏目玲子]: 是呀,可是說是黑G交易。。
10:50 [夏目玲子]: 現在戰歌AH裡面,一個寵物也可以賣88888G
10:51 [夏目玲子]: 我買了是不是可以說對方黑G
10:51 [艾可米安娜]: 同樣回到上述的回覆,您可以舉報,gm再轉由相關單位進行查詢。
10:51 [夏目玲子]: 一個 [歌唱水晶之斧]賣52000G…
10:52 [艾可米安娜]: 是的。
10:52 [夏目玲子]: [野熊之碎裂護軀]=22222G
10:53 [夏目玲子]: 我朋友只是做了相同的事情,就因為完全不知道是誰的一個買家有黑G可能,就被連累到了
10:53 [艾可米安娜]: 這部分的結果仍是需要以相關單位查詢結果為主。
10:53 [夏目玲子]: 這個我清楚。我是說,相關單位查到的是:買家用的是黑G
10:54 [艾可米安娜]: 是的。
10:54 [夏目玲子]: 可是無論買家是不是黑G,賣家用的是AH,並不是直接交易
10:54 [夏目玲子]: 賣家不知道對方是誰,也不知道是不是黑G,甚至也不能拒絕交易
10:55 [夏目玲子]: 這樣被一個黑G的人就可以隨意攻擊其他玩家了?
10:56 [艾可米安娜]: 因為gm不能確認每一位玩家的金錢來源,僅能建議玩家買/賣物品請使用市場價格,並且禁止在遊戲中涉及現實中交易,避免有收到黑金的可能。
10:56 [夏目玲子]: 可是這就是市場價格。。。。
10:57 [夏目玲子]: 如我剛才所說,AH現在還是有幾萬的綠裝
10:57 [艾可米安娜]: 請問您有問過多數的線上朋友,詢問寒冬長袍可以販售10萬金嗎?
10:57 [夏目玲子]: 既然開了幻化,這種需求就是存在
10:57 [夏目玲子]: 也沒幾個人會幻化
10:58 [夏目玲子]: 您的意思是說,吃魚翅的人太少,所以魚翅的價格就不是市場價咯?
10:58 [艾可米安娜]: 所謂的市場價格指的是大多數人可以接受的金額。
10:59 [夏目玲子]: 現在戰歌,任務物品AH列表,隨便找一下,都是1000多G的物品,這個任務才獎勵16G,請問是不是市場價
10:59 [夏目玲子]: 因為很多人買,我也買,所以我覺得是市場價。
11:00 [夏目玲子]: 稀有坐騎,出了,有人說願意用10萬G來收,其他隊友同意,這種事情也很常見,所以我覺得也是市場價。
11:00 [夏目玲子]: 為什麼一件稀有衣服,就不是市場價了呢?而且就算不是,也沒有人要求對方買,只是掛在AH而已啦。
11:00 [夏目玲子]: 覺得貴就不要買嘛
11:00 [艾可米安娜]: 好的,您覺得是市場價,gm尊重您的決定,若您收受金額不是黑金,那您就沒事喔。
11:01 [夏目玲子]: 也就是說,如果一個團友,開了一個坐騎團,但是他用的是黑金,所以其他人就必須永久停權咯?
11:01 [夏目玲子]: 即使他們完全不知情
11:01 [艾可米安娜]: 這就要轉相關單位查詢囉。
11:01 [夏目玲子]: 是呀,我是說,如果確實是黑G呢
11:01 [夏目玲子]: 我從未否認買家用的是黑G,我是說賣家不知情。
11:02 [艾可米安娜]: 因為沒有查詢結果,故無法確認是否為黑金。
11:02 [夏目玲子]: 哦,好的明白了。感謝您
11:02 [艾可米安娜]: 麻煩您了,請問還有其他問題需要艾可為您服務的嗎@~@?
11:03 [夏目玲子]: 最後一個問題,您的這些對白是代表智凡帝吧。。。那麼為了防止其他人也被攻擊到,我還是會把對白貼出來,OK?
11:03 [夏目玲子]: 以免有更多人因此躺著也中箭
11:04 [艾可米安娜]: 可以的,關於gm和您之間的對話,也是有記錄的,請您放心。
11:04 [夏目玲子]: 嗯,好的。感謝您。謝謝
11:04 [艾可米安娜]: 不用客氣喔,若您沒有其他問題,艾可就不打擾您進行遊戲囉,若遊戲中有再次遇到問題,請再由GM為您服務,艾可祝您遊戲愉快^_^!
11:05 [夏目玲子]: 嗯嗯,您辛苦了XD
11:05 [艾可米安娜]: 謝謝您,再見囉*~^_^~*
再次聲明,我不認為此GM有任何工作上的疏失。貼出此對白,只是敬告各位玩家注意。我對此GM以及其他GM的工作表示滿意。
Recursive Enumerator
using System;
using System.Collections.Generic;
namespace SecretNest.RecursiveEnumerator
{
/// <summary>
/// Get the enumerator for querying the parents of specified item.
/// </summary>
/// <typeparam name="T">Item type</typeparam>
/// <param name="current">Item for querying parents</param>
/// <returns>Enumerator of parents querying</returns>
public delegate IEnumerator<T> GetParentsEnumerator<T>(T current);
/// <summary>
/// Enumerator for querying parents
/// </summary>
/// <typeparam name="T">Item type</typeparam>
public class Enumerator<T> : IEnumerator<T>
{
T current, initial;
Queue<T> notQueried = new Queue<T>();
HashSet<T> queried = new HashSet<T>(); //for avoiding duplicated query
Queue<T> rollbackHistory = new Queue<T>(); //for soft reset
Queue<T> history = new Queue<T>(); //for soft reset
IEnumerator<T> activeQuery;
/// <summary>
/// Callback for getting the enumerator, which is used for querying the parents of specified item.
/// </summary>
public GetParentsEnumerator<T> GetParentsEnumeratorCallback { get; set; }
/// <summary>
/// Constructor
/// </summary>
/// <param name="initial">Initial item</param>
public Enumerator(T initial)
{
notQueried.Enqueue(initial);
this.initial = initial;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="initial">Initial item</param>
/// <param name="callback">Callback for getting the enumerator, which is used for querying the parents of specified item.</param>
public Enumerator(T initial, GetParentsEnumerator<T> callback)
{
notQueried.Enqueue(initial);
this.initial = initial;
GetParentsEnumeratorCallback = callback;
}
/// <summary>
/// Gets the current element in the collection.
/// </summary>
public T Current
{
get { return current; }
}
bool disposed;
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (!disposed)
{
if (disposing)
{
current = default(T);
notQueried = null;
queried = null;
history = null;
}
disposed = true;
}
}
/// <summary>
/// Gets the current element in the collection.
/// </summary>
object System.Collections.IEnumerator.Current
{
get { return current; }
}
/// <summary>
/// Skip same items
/// </summary>
public bool SkipSameItems { get; set; }
/// <summary>
/// Advances the enumerator to the next element of the collection.
/// </summary>
/// <returns>true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection. </returns>
public bool MoveNext()
{
if (disposed) throw new ObjectDisposedException(null);
if (rollbackHistory.Count > 0)
{
current = rollbackHistory.Dequeue();
history.Enqueue(current);
return true;
}
if (activeQuery != null)
{
here:
if (activeQuery.MoveNext())
{
if (SkipSameItems && history.Contains(activeQuery.Current)) { goto here; }
current = activeQuery.Current;
history.Enqueue(current);
notQueried.Enqueue(current);
return true;
}
else
{
activeQuery = null;
}
}
if (GetParentsEnumeratorCallback != null)
{
while (notQueried.Count != 0)
{
T item = notQueried.Dequeue();
if (!queried.Contains(item))
{
IEnumerator<T> enumerator = GetParentsEnumeratorCallback(item);
queried.Add(item);
here:
if (enumerator != null)
{
if (enumerator.MoveNext())
{
activeQuery = enumerator;
if (SkipSameItems && history.Contains(enumerator.Current)) { goto here; }
current = enumerator.Current;
history.Enqueue(current);
notQueried.Enqueue(current);
return true;
}
else
{
enumerator = null;
}
}
}
}
}
return false;
}
/// <summary>
/// Sets the enumerator to its initial position, which is before the first element in the collection. Keep all histories for caching.
/// </summary>
public void Reset()
{
if (disposed) throw new ObjectDisposedException(null);
while (history.Count > 0)
{
rollbackHistory.Enqueue(history.Dequeue());
}
current = default(T);
}
/// <summary>
/// Sets the enumerator to its initial position, which is before the first element in the collection. Reset all data, and close active sub-query.
/// </summary>
public void HardReset()
{
if (disposed) throw new ObjectDisposedException(null);
queried.Clear();
notQueried.Clear();
notQueried.Enqueue(initial);
history.Clear();
activeQuery = null;
current = default(T);
}
}
}
IIS FTP Bug on Listing Virtual Directories
Some virtual directories are added to my FTP server. But even virtual directories listing option is enabled, these folder still not been seen.
I can use CWD to go into that virtual folder, but cannot see it.
I’ve tried to restart IIS and the whole server.
成就:大災變區域的長者 坐標
大地神殿的長者石印:大地神殿50 55
奧丹姆的長者曼卡夫:卡爾吐特之墓66:19
奧丹姆的長者塞卡彌:亞蒙廢墟32:63
暮光高地的長者火鬍:登瓦德廣場50:70
暮光高地的長者暗羽:桑德馬51:33
海加爾的長者風歌:馬洛尼聖地27:62
諾達希爾的長者恒影:諾達希爾聯盟傳送點外27:62
瓦許伊爾的長者月槍:畢耶拉藍山脊57:86
地深之源的長者深爐:石爐28:69