Skip to content

Instantly share code, notes, and snippets.

View hagbarddenstore's full-sized avatar

Kim Johansson hagbarddenstore

View GitHub Profile
/**
* Install-Package mongocsharpdriver
* Install-Package newtonsoft.json
*/
var document = new BsonDocument
{
{ "_id", Guid.NewGuid() },
{ "Name", "Hagbarddenstore" },
{
class Person
{
public Person(string firstname, string lastname)
{
Firstname = firstname;
Lastname = lastname;
}
public string Firstname { get; private set; }
public static class CachedReflector
{
private static readonly Dictionary<Type, IEnumerable<PropertyInfo>> _cachedProperties = new Dictionary<Type, IEnumerable<PropertyInfo>>();
public static IEnumerable<PropertyInfo> GetProperties(Type type)
{
IEnumerable<PropertyInfo> properties;
if (!_cachedProperties.TryGetValue(type, out properties))
{
1. Tasks are recieved on the "tasks"-queue.
2. A worker dequeues a task.
3. The worker locks the entity related to the task.
4. The worker executes the task with the given entity.
5. The worker releases the locked entity.
int ParseTime(string input)
{
var totalMinutes = 0;
input = Regex.Replace(input.ToLower(), "[^\\d|m|h]", string.Empty);
var hoursMatch = Regex.Match(input, "(?<Hours>\\d+)h");
if (hoursMatch.Success)
{
class Page
{
public Guid Id { get; set; }
public DateTime CreatedOn { get; set; }
public Dictionary<string, string> Title { get; set; }
public Dictionary<string, string> Content { get; set; }
}
@hagbarddenstore
hagbarddenstore / Exception.cs
Created July 17, 2014 11:56
ReSharper template to create .NET exceptions that are serializable.
namespace $NAMESPACE$
{
[System.SerializableAttribute]
public class $NAME$ : System.Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="$NAME$"/> class.
/// </summary>
public $NAME$()
{
from match in Regex.Matches(actionRoute.Url, "\\{(\\w+)\\}").OfType<Match>()
let parameterName = match.Groups[1].Value
join parameter in action.GetParameters() on parameterName.ToLower() equals parameter.Name.ToLower()
select new { Name = parameterName, Parameter = parameter }
struct TileType
{
public static readonly TileType Water = new TileType('~', false, 0.0, "Water", null, "water.png");
public static readonly TileType Sand = new TileType('§', true, 0.75, "Sand", null, "sand.png");
public static readonly TileType Dirt = new TileType('#', true, 1.0, "Dirt", null, "dirt.png");
public static readonly TileType Grass = new TileType('"', true, 1.0, "Grass", null, "grass.png");
public static readonly TileType Pebbles = new TileType('*', true, 1.0, "Pebbles", null, "pebbles.png");
public static readonly TileType Rock = new TileType('^', false, 0.0, "Rock", null, "rocks.png");
public static readonly TileType Tree = new TileType('†', true, 0.5, "Tree", null, "tree.png");
void Main()
{
var s = File.ReadAllLines("C:\\Users\\kim\\Desktop\\ReportingEvents.log").Last(x => x.ToLower().Contains("installation successful")).Substring(39,19);
Console.WriteLine(s);
}