Skip to content

Instantly share code, notes, and snippets.

@Buildstarted
Buildstarted / JDictionary.cs
Created August 11, 2011 16:55
Simple ExpandoObject-Like dictionary for NetwonSoft's Json.Net parser
public class JDictionary {
private List<JDictionary> items;
public string Key { get; set; }
public object Value { get; set; }
public JDictionary() {
items = new List<JDictionary>();
}
public JDictionary this[int index] {
@Buildstarted
Buildstarted / Graph.cs
Created August 12, 2011 22:19
Data hold for graphing data
public namespace Graphing {
public class Graph<TX, TY> {
private readonly List<GraphData<TX, TY>> _data;
public Graph() {
_data = new List<GraphData<TX, TY>>();
}
public GraphData<TX, TY> this[int index] {
get { return _data[index]; }
@Buildstarted
Buildstarted / IEnumerableRangeTest.cs
Created October 12, 2011 23:18
Creating an IEnumerable<int> from a string
//Thanks to BLUEPIXY for adding -number handling and overall a better implementation
[TestFixture]
public class IEnumerableRangeTest {
static public IEnumerable<int> GetRange(int start, int end){
int step = (start > end)? -1:1;
for (int i = start; true ; i += step){
yield return i;
if(i == end) break;
}
}
@Buildstarted
Buildstarted / HomeController.cs
Created November 17, 2011 16:21 — forked from Antaris/HomeController.cs
An updated model binder that supports async and non-async file uploads.
namespace AsyncUpload.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
return View();
}
@Buildstarted
Buildstarted / removed.cs
Created December 3, 2011 07:12
blah.cs
[Fact]
public void MessageAddedToRoomWithHashtagParsed() {
string expected = "<a href=\"#/rooms/hashtag\" title=\"#hashtag\">#hashtag</a>";
string clientId = Guid.NewGuid().ToString();
var repository = new InMemoryRepository();
var room = new ChatRoom() { Name = "hashtag" };
var user = new ChatUser() { Name = "testhashtaguser", Id = clientId };
repository.Add(room);
function createProfile(profileContainer, profile) {
var expand = $("li.user div[data-val-gravatar='" + profile.hash + "']");
var twitter = loadTwitter(profile);
var p = {
hash: profile.hash,
bio: {
name: profile.formatted,
about: profile.aboutMe,
hasTwitter: twitter != null
public class HomeController : Controller
{
//
// GET: /Home/
private IEventStream stream;
public HomeController(IEventStream stream)
{
this.stream = stream;
}
<pre>@if(someBool){<text>output</text>}</pre>
<pre>@if(someBool){
<text>output</text>
}</pre>
The above items create different output.
Specifically whitespace between { } is maintained when it shouldn't be on the second one.
The expected output for both statements should simply be "<pre>output</pre>".
@Buildstarted
Buildstarted / gist:1649144
Created January 20, 2012 19:33
Perform.This() sample usage
//write this to the once every 5 seconds for 5 iterations
Perform.This(() => {
Console.WriteLine(DateTime.UtcNow);
})
.Every(TimeSpan.FromSeconds(5))
.For(5)
.Start();
//write to the console in 10 seconds
Perform.This(() => {
@Buildstarted
Buildstarted / Perform.cs
Created January 20, 2012 22:16
Perform.This() method for initiating delayed and repeating actions
public class Perform
{
private readonly Action _action;
private int _delay;
private int _interval = Timeout.Infinite;
private int _iterations = int.MinValue;
private int _iterationsPerformed = 0;
private Timer _timer;
private int _until;