View Colorful_Console_16.cs
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.Drawing; | |
using Console = Colorful.Console; | |
namespace lolcmd | |
{ | |
class Program | |
{ | |
private static Random random = new Random(); |
View ServiceHelper.cs
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.ServiceModel; | |
public class ServiceHelper | |
{ | |
#region Public Methods | |
/// <summary> | |
/// WCF proxys do not clean up properly if they throw an exception. This method ensures that the service proxy is handled correctly. | |
/// Do not call TService.Close() or TService.Abort() within the action lambda. |
View KeyLockerExample.cs
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
class KeyLockerExample | |
{ | |
static readonly ThreadState[] StopStates = { ThreadState.AbortRequested, ThreadState.Aborted }; | |
static void Main() | |
{ | |
var threads = new List<Thread>(); | |
var sw = new Stopwatch(); | |
var timelimit = new TimeSpan(0, 0, 30); |
View KeyLocker.cs
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 KeyLocker : IDisposable | |
{ | |
private static readonly ConcurrentDictionary<object, object> Locks = new ConcurrentDictionary<object, object>(); | |
private readonly object _locker; | |
public KeyLocker(object key) | |
{ | |
_locker = Locks.GetOrAdd(key, new object()); | |
Monitor.Enter(_locker); | |
} |
View bad_code.cs
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 interface IUserService | |
{ | |
User GetUser(string userName); | |
} | |
public static class UserService : IUserService | |
{ | |
public User GetUser(string userName) | |
{ | |
using(var context = new SomeDbContext()) |
View linq.js
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
/*-------------------------------------------------------------------------- | |
* linq.js - LINQ for JavaScript | |
* ver 2.2.0.2 (Jan. 21th, 2011) | |
* | |
* created and maintained by neuecc <ils@neue.cc> | |
* licensed under Microsoft Public License(Ms-PL) | |
* http://neue.cc/ | |
* http://linqjs.codeplex.com/ | |
*--------------------------------------------------------------------------*/ |
View Surrogate.cs
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
class Parent { | |
DateTime CreatedOn {get;set;} | |
} | |
class DateTimeSurrogate { | |
long Value {get;set;} | |
} | |
//will other system need to mimic above structure or can other system deserialize as |
View MyNameValueInfo.cs
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
[DataContract] | |
public class MyNameValueInfo | |
{ | |
[DataMember(Order = 1)] | |
public string Name { get; set; } | |
[DataMember(Order = 2)] | |
public object Value { get; set; } | |
} |
View MyNameValueInfoSurrogate.cs
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
[DataContract] | |
public class MyNameValueInfoSurrogate | |
{ | |
//string is serializable so we'll just copy this property back and forth | |
[DataMember(Order = 1)] | |
public string Name { get; set; } | |
//byte[] is serializable so we'll need to convert object to byte[] and back again | |
[DataMember(Order = 2)] | |
public byte[] Value { get; set; } |
View plugin-page.php
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
<div class="bootstrap-wrapper"> | |
<button class="btn btn-primary">Click me</button> | |
</div> |
NewerOlder