This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Dependency Injection a Inversion of Control | |
| https://twitter.com/geekovo/status/290061513300000768 | |
| http://rarous.net/weblog/431-dip-ioc-a-di-dil-prvni.aspx | |
| http://rarous.net/weblog/432-dip-ioc-a-di-dil-druhy.aspx | |
| http://rarous.net/weblog/433-dip-ioc-a-di-dil-treti.aspx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $path = "~\AppData\Roaming\ncrunch2012\user.dat" | |
| ri -Force $path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ILogger logger = NullLogger.Instance; | |
| public ILogger Log | |
| { | |
| get { return logger; } | |
| set { logger = value ?? NullLogger.Instance; } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Task<Result> ProcessInner(ConnectorRequest message, int attempts) | |
| { | |
| return inner.ProcessMessageAsync(message).ContinueWith(t => | |
| { | |
| if (t.Result.IsSuccess || attempts == 0) | |
| return t.Result; | |
| return ProcessInner(message, attempts--).Result; | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| param( | |
| [Parameter(Position = 0, Mandatory = $true)]$serverIP, | |
| [Parameter(Position = 1, Mandatory = $true)]$mountServerName, | |
| $mountDirectory = "c:\mnt\") | |
| Import-Module MkLink # https://gist.github.com/2891103 | |
| if (-not (Test-Path $mountDirectory)) { | |
| Write-Error "Invalid mount directory - $mountDirectory" | |
| exit 81 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IEnumerable<XmlSchemaElement> FindElements(XmlSchemaObjectCollection items, string elementName) | |
| { | |
| foreach (XmlSchemaObject item in items) | |
| { | |
| var el = item as XmlSchemaElement; | |
| if (el != null && el.Name == elementName) | |
| return new[] { el }; | |
| var ct = item as XmlSchemaComplexType ?? el.SchemaType as XmlSchemaComplexType; | |
| if (ct == null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void RefreshProxyQueue() | |
| { | |
| var proxyQueue = queueFactory.Create(); | |
| var query = from provider in proxyProviders.ToObservable() | |
| from proxy in provider.GetActualProxyList() | |
| from isAvailable in IsAvailable(proxy) | |
| where isAvailable | |
| select proxy; | |
| query.Subscribe(proxyQueue.Enqueue); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| query.Subscribe(x => | |
| { | |
| Task.Factory.StartNew(() => | |
| { | |
| if (IsAvailable(x)) | |
| proxyQueue.Enqueue(x); | |
| }, TaskCreationOptions.LongRunning); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| string elementName = table.SelectNodes("tr/td")[0].InnerText; | |
| if (elementName.Trim() == string.Empty) | |
| //... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static XElement XSection<T>(string name, T[] items) | |
| { | |
| if (items == null || !items.Any()) | |
| return null; | |
| return new XElement(name, from dynamic item in items select item.ToXElement()); | |
| } |