Skip to content

Instantly share code, notes, and snippets.

View alimbada's full-sized avatar

Ammaar Limbada alimbada

View GitHub Profile
void Main()
{
var ignores = new Regex[]
{
new Regex(@"Approval"),
new Regex(@"Test"),
new Regex(@"Demo")
};
var serviceControl = @"C:\Code\Particular\ServiceControl\src\";
Util.Image("http://yuml.me/diagram/scruffy;scale:150/class/" + String.Join(",", GetDependencies(serviceControl, ignores))).Dump();
@alimbada
alimbada / UnlockScreen.cmd
Created May 16, 2015 14:20
Unlocks the screen on a remote Windows machine (so that I can stream games from it with Steam In-Home Streaming)
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$sessionid=((quser $env:USERNAME | select -Skip 1) -split '\s+')[2]; tscon $sessionid /dest:console" 2> UnlockErrors.log
@alimbada
alimbada / Export-Chocolatey.ps1
Last active January 22, 2025 20:38
Export installed Chocolatey packages as packages.config - thanks to Matty666
#Put this in Export-Chocolatey.ps1 file and run it:
#.\Export-Chocolatey.ps1 > packages.config
#You can install the packages using
#choco install packages.config -y
Write-Output "<?xml version=`"1.0`" encoding=`"utf-8`"?>"
Write-Output "<packages>"
choco list -lo -r -y | % { " <package id=`"$($_.SubString(0, $_.IndexOf("|")))`" version=`"$($_.SubString($_.IndexOf("|") + 1))`" />" }
Write-Output "</packages>"
@alimbada
alimbada / Export-WindowsFeatures.ps1
Last active April 25, 2023 02:13
Export installed Windows features as chocolatey script
dism /online /Get-Features /Format:Table | Select-String Enabled | % {($_ -split '\|', 2)[0].Trim()} | % { "choco install $_ -source windowsfeatures" }
git clean -xdf -e *.suo -e *.user -e */packages/*
@alimbada
alimbada / NuGetSolutionWideDownGrade.ps1
Created December 5, 2013 12:59
Commands for downgrading NuGet packages across a solution in Visual Studio using the Package Manager Console
$projects =Get-Project -All | Select @{ Name=”ProjectName”;Expression={$_.ProjectName}}, @{Name=”Has”;Expression={Get-Package $PackageName -Project $_.Name}} | where { $_.Has -and $_.Has.ToString() -eq '$PackageName $CurrentPackageVersion' }
$projects | select { Uninstall-Package $PackageName -ProjectName $_.ProjectName -Force }
$projects | select { Install-Package $PackageName -Version $PackageVersionToDowngradeTo -ProjectName $_.ProjectName }
@alimbada
alimbada / Wake.ps1
Last active January 29, 2025 10:55
PowerShell script for sending Wake On LAN magic packets to given machines/MAC address(es)
#######################################################
##
## Wake.ps1, v1.0, 2013
##
## Adapted by Ammaar Limbada
## Original Author: Matthijs ten Seldam, Microsoft (see: http://blogs.technet.com/matthts)
##
#######################################################
<#
@alimbada
alimbada / gist:3083937
Created July 10, 2012 15:11
Metro Style for WPF Button
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style
x:Key="ButtonFocusVisual">
<Setter
Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2" />
</ControlTemplate>
public abstract class CommandBase : ICommand
{
public abstract void Execute();
public virtual bool CanExecute()
{
return true;
}
@alimbada
alimbada / gist:2975897
Created June 23, 2012 00:08
Recursively nukes bin and obj directories in a source/directory tree.
for /d /r . %%d in (bin,obj) do @if exist "%%d" rd /s/q "%%d"
REM Remove extra %s if you want to run command straight from the command line, i.e.
REM for /d /r . %d in (bin,obj) do @if exist "%d" rd /s/q "%d"