Skip to content

Instantly share code, notes, and snippets.

class A
{
private object _locker = new object();
public event EventHandler Bang;
public void Foo()
{
new Thread(() =>
{
@alfeg
alfeg / gist:878596
Created March 20, 2011 19:37
Topshelf configurator example
RunConfiguration cfg = RunnerConfigurator.New(
x =>
{
x.ConfigureService<SomeClass>(c =>
{
c.WhenStarted(s => s.BootHost());
c.WhenStopped(s => s.ShutDownHost());
c.WhenPaused(s => s.ShutDownHost());
c.WhenContinued(s => s.BootHost());
c.HowToBuildService(
// Basic interfaces
/// <summary>
/// Wrapper of repository acces
/// </summary>
/// <typeparam name="T"></typeparam>
public interface IDataRepository<T> where T : class
{
/// <summary>
/*db.Blogs
.Include("Posts")
.Include("Posts.Comments")
.Where(x => x.Id == 1)
.ToList();*/
SELECT [Project2].[Id] AS [Id],
@alfeg
alfeg / GenericHelpers.cs
Created October 13, 2011 11:02
Html helper for script jquery templates
public static class GenericHelpers
{
public static HtmlTemplate HtmlTemplate(this HtmlHelper html, object htmlAttributes)
{
return new HtmlTemplate(html, htmlAttributes);
}
}
@alfeg
alfeg / gist:1514174
Created December 23, 2011 13:12
Perlin Fire
// Variable usage: (* marks globals, all other variables are used for various purposes by various parts of the code)
// a = calculator
// b* = random data
// c* = main canvas
// d* = main canvas style / main canvas context
// e = calculator
// f =
// g* = main canvas composite operations
// h* = 300 (height)
// i = counter
@alfeg
alfeg / gist:1899750
Created February 24, 2012 09:36
MVC4 SPA Todo Sample
/// <reference path="_references.js" />
(function (window, undefined) {
// Define the "MyApp" namespace
var MyApp = window.MyApp = window.MyApp || {};
// TodoItem class
var entityType = "TodoItem:#TodoApp.Models";
MyApp.TodoItem = function(data) {
var self = this;
protected static bool IsListSuitableForSimpleAdmin(IList<Record> records)
{
bool returnValue = false;
if (records != null)
{
int sundayCount = 0;
int mondayCount = 0;
int tuesdayCount = 0;
int wednesdayCount = 0;
int thursdayCount = 0;
/// <summary>
/// Controls access to the cached values.
/// </summary>
private static ReaderWriterLockSlim mutex = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
/// <summary>
/// Gets a values from the cache, adding it if required.
/// </summary>
/// <typeparam name="T">The type of the value.</typeparam>
/// <param name="cacheParameters">The name of the value used to identify it in the cache.</param>
@alfeg
alfeg / RestClientExtensions.cs
Created August 3, 2012 20:54
Restsharp client extensions
using System;
using System.Diagnostics;
using Fasterflect;
using RestSharp;
namespace xxx.xxx.Rest.Client
{
public static partial class RestClientExtensions
{
public static ClientResponse ExecuteItDynamic(this IRestClient client, IRestRequest request)