Skip to content

Instantly share code, notes, and snippets.

View dennisroche's full-sized avatar
🐱

Dennis Roche dennisroche

🐱
View GitHub Profile
@dennisroche
dennisroche / Retry.ps1
Last active August 29, 2015 14:05
Retry Powershell Cmdlet
function Retry {
[CmdletBinding()]
param (
[Parameter(Mandatory=$false)]
[Alias("Attemps")]
[int]$maxAttempts = 3,
[Parameter(Mandatory=$false)]
[Alias("Delay")]
[int]$secondsBeforeRetrying = 5,
@dennisroche
dennisroche / TeamCityBackup.ps1
Last active August 29, 2015 14:11
Backup TeamCity
#TeamCityBackup
#Requires Version 4
#Requires -RunAsAdministrator
Param
(
[Parameter(Mandatory, HelpMessage="Team City installation directory, e.g. C:\TeamCity")]
[ValidateNotNullOrEmpty()]
[ValidateScript({ Test-Path $_ })]
[String]$TeamCityInstallation = "C:\TeamCity",
@dennisroche
dennisroche / gist:4b7c84756f2556d0b024
Created June 16, 2015 05:04
Attempt at Xamarin Renderer that forces a page to be displayed as Landscape or Portrait. It currently does not work.
public class OrientationNavigationRenderer : NavigationRenderer
{
protected override Task<bool> OnPushAsync(Page page, bool animated)
{
if (page is RequestSignaturePadView)
{
var landscapePage = new ForceLandscapeViewController(page);
PushViewController(landscapePage, animated);
return Task.FromResult(true);
}
@dennisroche
dennisroche / PruneRemoteBranches.sh
Last active March 16, 2016 06:15
Git, Prune Remote Branches that have been merged into origin/master
# Needs to executed in git bash, powershell with posh-git won't work.
# NB, change grep -v master to be the branch you want to check, e.g. grep -v development
# Preview
git fetch -p origin && git branch -r --merged | grep origin | grep -v '>' | grep -v master | xargs -L1 | cut -d"/" -f2- | xargs -d ' '
# Actual
git fetch -p origin && git branch -r --merged | grep origin | grep -v '>' | grep -v master | xargs -L1 | cut -d"/" -f2- | xargs git push origin --delete
@dennisroche
dennisroche / posh-git-helpers.ps1
Last active May 2, 2016 10:15
PoshGit Helpers
# clean remote and local branches
function Git-Prune {
git fetch origin
Write-Host "Pruning remote branches" -ForegroundColor Magenta
git remote prune origin
Write-Host "Pruning local branches that have been merged to master" -ForegroundColor Magenta
git branch --merged $Commit |
? { $_ -notmatch '(^\*)|(^. master$)' } |
% { git branch $(if($Force) { '-D' } else { "-d" }) $_.Substring(2) }
}
@dennisroche
dennisroche / MessagingCenterEx.cs
Created May 4, 2016 05:27
Xamarin.Forms type-safe MessagingCenter
using System;
using Xamarin.Forms;
// ReSharper disable CheckNamespace
// Using global:: namespace
public static class MessagingCenterEx
{
private class MessagingCenterSender
{

GitHub Markdown Style

Modified from https://github.com/sindresorhus/github-markdown-css.

Edited to work inside VSCode Markdown preview.

To use GitHub style markdown preview in VSCode, add the following to your local or workspace preferences.

@dennisroche
dennisroche / Remove-GitMergedBranches.ps1
Created September 23, 2016 06:04
A posh-git script that identifies local branches that have been merged to `master`.
function Remove-GitMergedBranches {
Write-Output "Fetching latest"
git fetch origin --prune
$currentBranch = & git rev-parse --abbrev-ref HEAD
if ($currentBranch -ne "master") {
Write-Output "Changing branch to master"
git checkout master
}
<#
.SYNOPSIS
This Azure Automation runbook automates the scheduled shutdown and startup of virtual machines in an Azure subscription.
.DESCRIPTION
The runbook implements a solution for scheduled power management of Azure virtual machines in combination with tags
on virtual machines or resource groups which define a shutdown schedule. Each time it runs, the runbook looks for all
virtual machines or resource groups with a tag named "AutoShutdownSchedule" having a value defining the schedule,
e.g. "10PM -> 6AM". It then checks the current time against each schedule entry, ensuring that VMs with tags or in tagged groups
are shut down or started to conform to the defined schedule.