This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Git functions | |
# Mark Embling (http://www.markembling.info/) | |
# Is the current directory a git repository/working copy? | |
function isCurrentDirectoryGitRepository { | |
if ((Test-Path ".git") -eq $TRUE) { | |
return $TRUE | |
} | |
# Test within parent dirs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ChildItem $psScriptRoot -filter *.ps1 | foreach { . $_.FullName } | |
if(Get-Module prompt) { Remove-Module prompt } | |
$prompt_kind = if($args[0]) { $args[0] } else { "bash" } | |
if($prompt_kind -eq "bash") { | |
function prompt { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class NotifyPropertyChangedExtensions | |
{ | |
public static IObservable<TProp> GetPropertyChanges<TSource, TProp>(this TSource source, Expression<Func<TSource, TProp>> propertySelector, bool lightCompile = true) | |
where TSource : INotifyPropertyChanged | |
{ | |
var propertyName = GetPropertyName(propertySelector); | |
return Observable | |
.FromEvent<PropertyChangedEventHandler, PropertyChangedEventArgs>( | |
h => new PropertyChangedEventHandler((s, e) => h(e)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
********************** | |
Windows PowerShell Transcript Start | |
Start time: 20110523192949 | |
Username : NORTHHORIZON\daniel | |
Machine : POLARIS (Microsoft Windows NT 6.1.7601 Service Pack 1) | |
********************** | |
Transcript started, output file is C:\Users\daniel\Documents\PowerShell_transcript.20110523192949.txt | |
PS C:\Users\daniel> | |
2 > Import-Module powershellpack | |
PS C:\Users\daniel> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param([string] $CountProperty = 'Count', | |
[string] $NameProperty = 'Name', | |
[double] $Width = 400, | |
[double] $Height = 300, | |
[string] $WindowTitle = 'Pie Graph', | |
[string] $ChartTitle = $null, | |
[Parameter(ValueFromPipeline = $true)] $Items, | |
[switch] $Show = $false) | |
begin { | |
Import-Module wpk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// doesn't detect Never() | |
public static IObservable<bool> IsAlive_Merge<T>(this IObservable<T> source, TimeSpan timeout, IScheduler sched) | |
{ | |
return source.Select(_ => true) | |
.Merge(source.Select(_ => false).Throttle(timeout, sched)) | |
.DistinctUntilChanged(); | |
} | |
// D.Moore, 29 May: using the buffer count should cause this to fire as soon as it's available. | |
public static IObservable<bool> IsAlive_Buffer<T>(this IObservable<T> source, TimeSpan timeout, IScheduler sched) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Console.ReadLine(); | |
var sched = Scheduler.TaskPool; | |
var count = Observable | |
.Return(new Unit(), sched) | |
.Repeat() | |
// Use NewThread to avoid bias on the cutoff. | |
.TakeUntil(Observable.Timer(TimeSpan.FromSeconds(5), Scheduler.NewThread)) | |
.Count() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private bool IsIncluded(LazyMemberInfo memberInfo) | |
{ | |
var accessors = memberInfo.GetAccessors().Where(a => a != null); | |
var types = accessors.Select(m => m as Type ?? m.DeclaringType); | |
var assemblies = types.Select(t => t.Assembly).Distinct().Where(a => a != null); | |
var scopeSets = new[] | |
{ | |
// Local Scopes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-MeetupRsvps([string]$eventId, [string]$apiKey) { | |
$nameWord = "[\w-']{2,}" | |
$regex = "^(?'first'$nameWord) ((\w\.?|($nameWord )+) )?(?'last'$nameWord)|(?'last'$nameWord), ?(?'first'$nameWord)( \w\.|( $nameWord)+)?$" | |
function Get-AttendeeInfo { | |
process { | |
$matches = $null | |
$answer = $_.answers.answers_item | |
if(-not ($_.name -match $regex)) { $answer -match $regex | Out-Null } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var target = new Border{ Background = Brushes.SteelBlue, Width = 200, Height = 200 }; | |
var win = new Window{ Content = target }; | |
var mouseDown = Observable.FromEventPattern<MouseEventArgs>(target, "MouseLeftButtonDown"); | |
var mouseMove = Observable.FromEventPattern<MouseEventArgs>(target, "MouseMove"); | |
var mouseUp = Observable.FromEventPattern<MouseEventArgs>(target, "MouseLeftButtonUp"); | |
// dragEvents is IObservable<IObservable<EventPattern<MouseMoveEvent>>> | |
// The first dimmension represents the sequence of discrete drag "sessions" | |
// The second dimmension represents the sequence of moves within that drag |
OlderNewer