Skip to content

Instantly share code, notes, and snippets.

@bpatra
bpatra / startfile
Created August 5, 2013 19:12
startfile for conemu
/BufferHeight 1000 powershell
@bpatra
bpatra / ExportAliasWitExeInPath.ps1
Last active December 5, 2020 18:24
Part of a PoSh profile to import/export all executables located under PATH.Export-AliasWithEXEInPATH is a function that exports alias with all .exe located under PATH environment variable. The alias exported file is named alias.txt and is exported next to the $PROFILE .ps1 file. These aliases are imported just before loading module PowerTab.
$aliasesPath = Join-Path -Path ([System.IO.Path]::GetDirectoryName($PROFILE)) -ChildPath "alias.txt"
function Export-AliasWithEXEInPATH
{
$aliasDict = @{}
$existingAlias = Get-Alias | ForEach-Object {$_.Name}
foreach($aliasName in $existingAlias)
{
$aliasDict.Add($aliasName,"")
}
@bpatra
bpatra / BasicUnion.cs
Last active December 5, 2020 18:22
The basic Union method in ExcelInterop
//builds the union range form the indices
private static Range Union(IEnumerable<int> rows)
{
Range range = null;
foreach (int row in rows)
{
var currentLine = ExcelAddIn.ActiveSheet.Range["A" + row + ":" + "C" + row];
range = range == null ? currentLine : ExcelAddIn.Application.Union(range, currentLine);
}
return range;
@bpatra
bpatra / restart_audioHDMIDrivers.sh
Last active December 5, 2020 18:51
PoSh script to restart drivers for HDMI sound
$devcon = "C:\Program Files (x86)\Windows Kits\8.1\Tools\x64\devcon.exe"
$audioID = "@HDAUDIO\FUNC_01&VEN_8086&DEV_2807&SUBSYS_80860101&REV_1000\4&36161A1D&0&0001"
$displayID = "@PCI\VEN_8086&DEV_0A16&SUBSYS_130D1043&REV_09\3&11583659&0&10"
. $devcon enable $audioID
. $devcon enable $displayID
. $devcon restart $audioID
. $devcon restart $displayId
Read-Host
@bpatra
bpatra / gist:9401745
Last active August 29, 2015 13:57
IFootballClub interface
public interface IFootballClub
{
string FullName { get; }
string NickName { get; }
int CreationYear { get; }
}
@bpatra
bpatra / gist:9401776
Last active August 29, 2015 13:57
IChampionship interface
public interface IChampionship
{
List<IFootballClub> CurrentChampionShipRanking { get; }
List<IFootballClub> UserBet { get; set; }
int GetGoodBetCount();
}
@bpatra
bpatra / gist:9516512
Last active August 29, 2015 13:57
IChampionshipBetViewModel
public interface IChampionshipBetViewModel : IDropTarget
{
ObservableCollection<IFootballClub> FootballClubs { get; }
ICommand ClickSave { get; }
}
@bpatra
bpatra / gist:9516759
Last active August 29, 2015 13:57
ChampionshipBetView
<UserControl x:Class="MvvMSample.Views.ChampionshipBetView" ... >
<UserControl.Resources>
<!-- go to github.com/bpatra/MvvMSample for complete implementation-->
</UserControl.Resources>
<UserControl.DataContext>
<Binding Path="ChampionshipBetViewModel" Source="{StaticResource Locator}" />
</UserControl.DataContext>
<StackPanel>
<ListView ItemsSource="{Binding FootballClubs}"
dd:DragDrop.IsDragSource="True"
@bpatra
bpatra / gist:9517801
Last active August 29, 2015 13:57
ChampionshipBetViewModel overview
public class ChampionshipBetViewModel : IChampionshipBetViewModel, IDropTarget
{
private readonly IChampionship _championship;
public ChampionshipBetViewModel(IChampionship championship)
{
_championship = championship;
FootballClubs = new ObservableCollection<IFootballClub>(championship.UserBet);
}
public ObservableCollection<IFootballClub> FootballClubs { get; private set; }
@bpatra
bpatra / gist:9518156
Last active August 29, 2015 13:57
First example of unit test when inserting the first row after the second one
[TestClass]
public class ChampionshipBetViewModel_DragAndDrop_Tests
{
private readonly ChampionshipBetViewModel _championshipBetViewModel;
private readonly Mock<IChampionship> _championShip;
private readonly IFootballClub _club1;
private readonly IFootballClub _club2;
private readonly IFootballClub _club3;
private readonly IFootballClub _club4;