Skip to content

Instantly share code, notes, and snippets.

Valeriu Caraulean vcaraulean

Block or report user

Report or block vcaraulean

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
View config_transform.msbuild
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="TransformConfig" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="TransformXml"
AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>
<Target Name="TransformConfig">
<TransformXml Source="$(SourcePath)\Web.config"
Transform="$(SourcePath)\Web.$(Configuration).config"
Destination="Web.config"/>
</Target>
@vcaraulean
vcaraulean / profile.ps1
Created Aug 17, 2010
Poweshell profile to combine posh-git and posh-hg prompts
View profile.ps1
Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)
$profilePath = split-path $profile
# Load posh-git and posh-hg modules from default profile directory
Import-Module $profilePath\posh-git\posh-git
Import-Module $profilePath\posh-hg\posh-hg
function prompt {
Write-Host($pwd) -nonewline
@vcaraulean
vcaraulean / rx.cs
Created Sep 18, 2015
TakeUntilIdleFor
View rx.cs
public static class Ex {
public static IObservable<T> TakeUntilIdleFor<T>(this IObservable<T> source, TimeSpan idleTime)
{
return Observable.Create<T>(o =>
{
var published = source.Publish();
var idle = published.Select(_ => Observable.Timer(idleTime)).Switch();
return new CompositeDisposable(published.Connect(), published.TakeUntil(idle).Subscribe(o));
});
}
@vcaraulean
vcaraulean / DoubleClickEvent
Created Nov 18, 2010
Mouse Double Click event implementation for Silverlight and Caliburn.Micro
View DoubleClickEvent
public static class DoubleClickEvent
{
public static readonly DependencyProperty AttachActionProperty =
DependencyProperty.RegisterAttached(
"AttachAction",
typeof (string),
typeof (DoubleClickEvent),
new PropertyMetadata(OnAttachActionChanged));
public static void SetAttachAction(DependencyObject d, string attachText)
@vcaraulean
vcaraulean / FieldNullValueAttribute.cs
Created May 6, 2011
Path for FileHelpers.com for handling empty (not provided) Guid values
View FieldNullValueAttribute.cs
// Replace constructor in line 53 with this one
public FieldNullValueAttribute(Type type, string nullValue)
: this(TypeDescriptor.GetConverter(type).ConvertFromString(nullValue))
{ }
@vcaraulean
vcaraulean / TestFixture.cs
Created May 9, 2011
Test case for BadUsageException
View TestFixture.cs
// Code is throwing exception:
// FileHelpers.BadUsageException : This engine works with record of type Country and you use records of type Country
// at FileHelpers.FileHelperEngine`1.WriteStream(TextWriter writer, IEnumerable`1 records, Int32 maxRecords) in FileHelperEngine.cs: line 558
// at FileHelpers.FileHelperEngine`1.WriteString(IEnumerable`1 records, Int32 maxRecords) in FileHelperEngine.cs: line 600
// at FileHelpers.FileHelperEngine`1.WriteString(IEnumerable`1 records) in FileHelperEngine.cs: line 591
// at FileHelpers.Tests.RunTimeClassesExtra.RuntimeClasses() in RunTimeClassExtra.cs: line 168
[Test]
public void RuntimeClasses()
{
@vcaraulean
vcaraulean / MyExtensions.cs
Last active Feb 5, 2016
Capture logging in LINQPad
View MyExtensions.cs
// Configuring
// Open Query Properties (F4) for My Extensions
// 1. Additional References: add NLog package from nuget
// 2. Additional Namespace Imports: add NLog.Config & NLog
public static class NLogExtensions
{
public static void LogToResults(string loggerName = "*", string minLevel="Trace")
{
var nlogConfig = @"
@vcaraulean
vcaraulean / starter.ps1
Created Jun 10, 2016
psake - passing in parameters
View starter.ps1
$scriptPath = $MyInvocation.MyCommand.Path
$scriptDir = Split-Path $scriptPath
Get-Module psake | Remove-Module
Import-Module ("C:\Dev\Tools\psake.4.6.0\tools\psake.psm1")
$envProperties = @{
"starterParam1"="start param value"
"starterParam2"=
@vcaraulean
vcaraulean / Program.cs
Last active Jul 11, 2016
Benchmarking NLog's TimeSource implementations
View Program.cs
// Required nuget packages:
// - NLog
// - BenchmarkDotNet
namespace BenchmarkNlogTimeSources
{
public class TimeSourceBenchmark
{
private readonly TimeSource _fastLocalTimeSource = new FastLocalTimeSource();
private readonly TimeSource _fastUtcTimeSource = new FastUtcTimeSource();
private readonly TimeSource _accurateLocalTimeSource = new AccurateLocalTimeSource();
You can’t perform that action at this time.