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
@pedropombeiro
pedropombeiro / install-ubuntu.sh
Last active March 25, 2020 21:46
Set up dev environment in Ubuntu
#!/bin/sh
rm -f ~/Downloads/*
# Adapt Firefox settings
def_Pfile=`cat "$HOME/.mozilla/firefox/profiles.ini" | sed -n -e 's/^.*Path=//p' | head -n 1`
# Enable FIDO U2F in Firefox
echo "user_pref(\"security.webauth.u2f\", \"true\");" >> $HOME/.mozilla/firefox/$def_Pfile/prefs.js
sudo apt update
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>();
}