This file contains 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
public class Test | |
{ | |
} |
This file contains 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
LICENSE_TAXONOMY_TEMPLATE_ID | |
bool hasLicensingTaxonomy = baseTemplates.Any(o => (o.ID.Equals(LICENSE_TAXONOMY_TEMPLATE_ID))); |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace DbLayerSample | |
{ | |
class Program | |
{ | |
static void Main(string[] args) |
This file contains 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
public double Sqrt(double a, int times) | |
{ | |
if (a < 0) | |
throw new Exception("Can not sqrt a negative number"); | |
double x = 1; | |
while (times-- > 0) | |
x = x / 2 + a / (2 * x); | |
return x; | |
} |
This file contains 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
public static decimal Sqrt(decimal i) | |
{ | |
decimal lo = 0; | |
decimal hi = i/2; | |
while(lo < hi) | |
{ | |
decimal mid = lo + (hi-lo)/2; | |
if(mid * mid > i ) | |
hi = mid - 1; | |
else if(mid * mid < i) |
This file contains 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
public class SimpleAsyncHost | |
{ | |
private HttpListener _httpListener; | |
private bool _stop; | |
public SimpleAsyncHost() | |
{ | |
_httpListener = new HttpListener(); | |
_httpListener.Prefixes.Add("http://localhost:10090/"); |
This file contains 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
public static class TaskExtentions | |
{ | |
public static async Task<T> WithTimeout<T>(this Task<T> task, int timeout) | |
{ | |
if (await Task.WhenAny(task, Task.Delay(timeout)) == task) | |
return await task; | |
return default(T); | |
} | |
} |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Net; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication1 | |
{ | |
class Program |
This file contains 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
public string ReverseWords(string text) | |
{ | |
var tarr = text.ToCharArray(); | |
//reverse the whole string first | |
reverse(tarr, 0, tarr.Length-1); | |
//reverse parts of the string | |
int start = 0; | |
for(int i = 0; i<tarr.Length; i++) | |
{ |
This file contains 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
public class StupidDictionary<T> | |
{ | |
private readonly int _numOfBuckets = 3; | |
private readonly bool _quiet; | |
private readonly int _capacity; | |
private int _totalCollisions; | |
private int[] _buckets; | |
private Slot[] _slots; | |
private int _lastIndex; | |
private decimal _count; |
OlderNewer