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
Dispatcher.CurrentDispatcher.UnhandledException += CurrentDispatcher_UnhandledException; | |
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; | |
[HandleProcessCorruptedStateExceptions] | |
[SecurityCritical] | |
void CurrentDispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) | |
{ | |
var ex = e.Exception; | |
string message = ex.NameAndMessage(); | |
string details = ex.GetDetailedMessage(); |
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 obj = LoadNetDll() | |
dllPath = '<full path to folder with .NET dll>\'; | |
if isdir(dllPath) | |
dllPath = fullfile(dllPath,'<.NET dll name>.dll'); | |
end | |
a = NET.addAssembly(dllPath); |
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
// | |
// http://stackoverflow.com/questions/52797/how-do-i-get-the-path-of-the-assembly-the-code-is-in | |
// | |
private static string AssemblyDirectory | |
{ | |
get | |
{ | |
string codeBase = Assembly.GetExecutingAssembly().CodeBase; | |
UriBuilder uri = new UriBuilder(codeBase); | |
string path = Uri.UnescapeDataString(uri.Path); |
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
#addin "Microsoft.Office.Interop.Outlook" | |
using Outlook = Microsoft.Office.Interop.Outlook; | |
// ... | |
Task("Send-email") | |
.Does(()=> | |
{ | |
//https://msdn.microsoft.com/en-us/library/office/bb644320.aspx | |
var reportFilePath = MakeAbsolute(File("testReport.html")).ToString(); |
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
$Outlook = New-Object -ComObject Outlook.Application | |
PM> $Mail = $Outlook.CreateItem(0) | |
PM> $Mail.to = "<email>" | |
PM> $Mail.Body = $dte.Debugger.CurrentStackFrame.Locals | ForEach-Object {$_.Name, $_.Type} | |
PM> $Mail.Send() |
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
#http://stackoverflow.com/questions/23219400/splitting-a-string-python-within-a-list | |
>>> import re | |
>>> i = 'john(is,great),paul,school' | |
>>> re.split(r',+(?=[^()]*(?:\(|$))', i) | |
['john(is,great)', 'paul', 'school'] |
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
#http://stackoverflow.com/questions/4284991/parsing-nested-parentheses-in-python-grab-content-by-level | |
def parenthetic_contents(string): | |
"""Generate parenthesized contents in string as pairs (level, contents).""" | |
stack = [] | |
for i, c in enumerate(string): | |
if c == '(': | |
stack.append(i) | |
elif c == ')' and stack: | |
start = stack.pop() | |
yield (len(stack), string[start + 1: i]) |
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
# | |
# from http://hmemcpy.com/2014/12/how-to-get-changes-files-from-svn-between-two-revisions-with-powershell/ | |
# | |
function Export-SvnDiff($repo, $fromRevision, $toRevision, $outputDirectory) | |
{ | |
$xpath = "/diff/paths/path[@kind='file' and (@item='added' or @item='modified')]" | |
[xml]$output = & svn diff -r $("{0}:{1}" -f $fromRevision, $toRevision) $repo --summarize --xml | |
$output | Select-Xml -XPath $xpath | % { $_.node."#text" } | % { | |
$targetFile = Resolve-FullPath (Join-Path $outputDirectory ($_ -replace $repo)) |
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
#Test Data | |
#$Data=("8/15/2014",3091),("8/14/2014",240),("8/13/2014",519),("8/12/2014",622),("8/11/2014",2132),("8/10/2014",1255),("8/9/2014",3240)|ForEach{[PSCustomObject][Ordered]@{'Date_to_Display'=$_[0];'Number_of_Computers'=$_[1]}} | |
$xlConditionValues=[Microsoft.Office.Interop.Excel.XLConditionValueTypes] | |
$xlTheme=[Microsoft.Office.Interop.Excel.XLThemeColor] | |
$xlChart=[Microsoft.Office.Interop.Excel.XLChartType] | |
$xlIconSet=[Microsoft.Office.Interop.Excel.XLIconSet] | |
$xlDirection=[Microsoft.Office.Interop.Excel.XLDirection] | |
$xl = new-object -ComObject Excel.Application |
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
# | |
# http://stackoverflow.com/questions/25331407/powershell-to-create-line-chart-from-excel | |
# | |
#Test Data | |
$Data=("8/15/2014",3091),("8/14/2014",240),("8/13/2014",519),("8/12/2014",622),("8/11/2014",2132),("8/10/2014",1255),("8/9/2014",3240)|ForEach{[PSCustomObject][Ordered]@{'Date_to_Display'=$_[0];'Number_of_Computers'=$_[1]}} | |
$xlConditionValues=[Microsoft.Office.Interop.Excel.XLConditionValueTypes] | |
$xlTheme=[Microsoft.Office.Interop.Excel.XLThemeColor] | |
$xlChart=[Microsoft.Office.Interop.Excel.XLChartType] |
NewerOlder