Skip to content

Instantly share code, notes, and snippets.

View pedropombeiro's full-sized avatar
🏠
Working from home

Pedro Pombeiro pedropombeiro

🏠
Working from home
View GitHub Profile
using System;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
namespace DeveloperOnTheFlow
{
public struct DispatcherSwitchTaskAwaitable
{
readonly ConfiguredTaskAwaiter configuredTaskAwaiter;
@pedropombeiro
pedropombeiro / Setup LINQPad.ps1
Last active August 29, 2015 14:27
Setup LINQPad with Dropbox
$queriesPath = "$linqpadDir\Queries"
$snippetsPath = "$linqpadDir\Snippets"
if (-not (Test-Path "$env:APPDATA\LINQPad")) {
[Void] (mkdir "$env:APPDATA\LINQPad")
}
$linqpadDir = "$HOME\Dropbox\Briefcase\Personal\Code\LINQPad"
$queriesPath | Out-File "$env:APPDATA\LINQPad\querypath.txt" -Encoding ASCII
$queriesPath | Out-File "$env:APPDATA\LINQPad\QueryLocations.txt" -Encoding ASCII
$snippetsPath | Out-File "$env:APPDATA\LINQPad\SnippetLocations.txt" -Encoding ASCII
@pedropombeiro
pedropombeiro / gist:f3f0a8fe8bff68d34345
Last active May 28, 2018 17:39
Pave Surface Pro 3
# Boxstarter options
$Boxstarter.RebootOk=$true # Allow reboots?
$Boxstarter.NoPassword=$false # Is this a machine with no login password?
$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot
# Basic setup
Update-ExecutionPolicy RemoteSigned
Set-CornerNavigationOptions -EnableUsePowerShellOnWinX
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Enable-MicrosoftUpdate
@pedropombeiro
pedropombeiro / gist:1edd32bdc5586e4592af
Last active January 5, 2018 09:24
Pave Development machine
# Boxstarter options
$Boxstarter.RebootOk=$true # Allow reboots?
$Boxstarter.NoPassword=$false # Is this a machine with no login password?
$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot
# Basic setup
Update-ExecutionPolicy RemoteSigned
Set-CornerNavigationOptions -EnableUsePowerShellOnWinX
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Enable-MicrosoftUpdate
@pedropombeiro
pedropombeiro / RetrofitSetup.java
Last active December 16, 2016 06:37
Spark Retrofit REST interface
RequestInterceptor requestInterceptor = new RequestInterceptor() {
@Override
public void intercept(RequestFacade request) {
String authenticationToken = ...;
if (authenticationToken != "")
request.addHeader("Authorization", String.format("Bearer %s", authenticationToken));
}
};
RestAdapter restAdapter = new RestAdapter.Builder()
/// <summary>
/// Deserializes a file from within a ZIP archive using the <see cref="BinaryFormatter"/> and passing a specified context object.
/// </summary>
/// <param name="zipFilePath">
/// The ZIP file path.
/// </param>
/// <param name="entryPath">
/// The path of the file to deserialize within the ZIP file.
/// </param>
/// <param name="deserializationContext">
@pedropombeiro
pedropombeiro / DataSegmentSpecs.cs
Created May 27, 2013 07:29
Sample Testeroids AAA-style constructor test, using triangulation in order to guarantee no hard-coded values are used in the production code.
public abstract class DataSegmentSpecs
{
[TriangulatedFixture]
public class after_instantiating_Sut_with_triangulated_values : SubjectInstantiationContextSpecification<DataSegment>
{
#region Context
[TriangulationValues(0x00001000u, 0x80100000)]
private uint InjectedAddress { get; set; }
@pedropombeiro
pedropombeiro / TypedFactoryDeclaration.cs
Created November 30, 2012 23:14
IFooFactory declaration
public interface IFooFactory
{
#region Public Methods and Operators
IFoo Create(int id);
#endregion
}
@pedropombeiro
pedropombeiro / UnityTypedFactoriesUsage.cs
Created November 30, 2012 23:11
Unity.TypedFactories usage
public void Main()
{
var unityContainer = new UnityContainer();
unityContainer
.RegisterTypedFactory<IFooFactory>()
.ForConcreteType<Foo>();
}
@pedropombeiro
pedropombeiro / gist:3846303
Last active October 11, 2015 10:38
Unity.AutoFactory usage
this.unityContainer
.RegisterAutoFactoryFor<ICustomer, Customer>()
.WithoutParameters();
this.unityContainer
.RegisterAutoFactoryFor<ICustomerViewModel, CustomerViewModel>()
.WithParam<ICustomer>();