Skip to content

Instantly share code, notes, and snippets.

Pascal Laurin plaurin

  • Montreal
Block or report user

Report or block plaurin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@plaurin
plaurin / DependenciesVisualizer.linq
Last active Aug 17, 2018
LinqPad query to generate a DMGL of projects, libraries and NuGet packages dependencies
View DependenciesVisualizer.linq
<Query Kind="Program" />
private string[] projectExtensionExclusions = new[] { ".vdproj", ".ndproj", ".wdproj", ".shfbproj" };
private string rootFolder = @"C:\Users\Pascal\Dev\MyProject";
void Main()
{
LoadAllProjects();
LoadAllPackagesConfig();
GenerateDGML(Path.Combine(rootFolder, "Dependencies.dgml"));
View gist:8177119
public Slice<T> GetSlice<T>(IEnumerable<Element<T>> elements, double totalSize, double sliceWidth)
{
if (!elements.Any()) return null;
if (elements.Count() == 1) return new Slice<T> { Elements = elements, Size = totalSize };
var sliceResult = GetElementsForSlice(elements, sliceWidth);
return new Slice<T>
{
Elements = elements,
@plaurin
plaurin / DocumentStoreBlobRepo.cs
Last active Dec 17, 2015
DocumentStore Repository using Blob storage
View DocumentStoreBlobRepo.cs
public class ProjectRepository
{
private CloudTable table;
private CloudBlobContainer container;
public ProjectRepository()
{
var connectionString = "...";
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
@plaurin
plaurin / DocumentStoreRepositoryUsage.cs
Last active Dec 15, 2015
Document store implementation usages
View DocumentStoreRepositoryUsage.cs
public class Project
{
public Guid Owner { get; set; }
public Guid Id { get; set; }
public string Name { get; set; }
public DateTime StartDate { get; set; }
public int Status { get; set; }
public List<Task> Tasks { get; set; }
}
@plaurin
plaurin / DocumentStoreRepository.cs
Last active Dec 15, 2015
Document store implementation for Windows Azure Table Storage service using the ElasticTableEntity class
View DocumentStoreRepository.cs
public class ProjectRepository
{
private CloudTable table;
public ProjectRepository()
{
var connectionString = "...";
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
var client = storageAccount.CreateCloudTableClient();
@plaurin
plaurin / ElasticTableEntity.cs
Created Mar 13, 2013
ElasticTableEntity is a reusable dynamic entity used for the Azure Table Storage Service
View ElasticTableEntity.cs
public class ElasticTableEntity : DynamicObject, ITableEntity,
ICustomMemberProvider // For LinqPad's Dump
{
public ElasticTableEntity()
{
this.Properties = new Dictionary<string, EntityProperty>();
}
public IDictionary<string, EntityProperty> Properties { get; private set; }
View ElasticTableEntityUsage.cs
var connectionString="...";
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
var client = storageAccount.CreateCloudTableClient();
var table = client.GetTableReference("Demo");
table.CreateIfNotExists();
// dynamic keyword to use a dynamic entity
dynamic entity = new ElasticTableEntity();
entity.PartitionKey = "Partition123";
@plaurin
plaurin / MiniProfiler.cs
Last active Dec 12, 2015
Example using MiniProfiler
View MiniProfiler.cs
MiniProfilerEF.Initialize_EF42(); // When using Code First
ConsoleProfiling.Start();
using (StackExchange.Profiling.MiniProfiler.Current.Step("StepName"))
{
using (var context = new Context())
{
var result = context.Entities
.Where(p => p.Property.StartsWith("Value"))
.ToList();
@plaurin
plaurin / SelfCompile
Created Oct 7, 2012
Self Compiling LinqPad query
View SelfCompile
void Main()
{
Environment.CurrentDirectory = Path.GetDirectoryName(Util.CurrentQueryPath);
Compiler.CompileFiles(Options.CreateOnDiskDll(
@namespace: "LinqPad.QueriesCompiler",
outputFile: "LinqPad.QueriesCompiler.dll")
.AddCodeFile(CodeType.LinqProgramTypes, Util.CurrentQueryPath))
.Dump("Successfully created assembly at " + DateTime.Now.ToLocalTime());
}
View MemoryAppenderUT.cs
[SetUp]
public void SetUp()
{
this.memoryAppender = new MemoryAppender();
BasicConfigurator.Configure(this.memoryAppender);
...
}
[Test]
You can’t perform that action at this time.