Skip to content

Instantly share code, notes, and snippets.

View constructor-igor's full-sized avatar

Igor Ziselman constructor-igor

View GitHub Profile
@constructor-igor
constructor-igor / UnhandledException.cs
Created December 27, 2016 09:26
UnhandledException in WPF
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();
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);
@constructor-igor
constructor-igor / AssemblyDirectory
Created October 24, 2016 21:40
AssemblyDirectory
//
// 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);
@constructor-igor
constructor-igor / Send email (outlook) from cake
Created October 16, 2016 08:52
Sending email (Outlook) from cake script.
#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();
$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()
@constructor-igor
constructor-igor / split-string-with-nested-sep
Created April 22, 2015 13:36
Splitting a String Python within a list
#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']
@constructor-igor
constructor-igor / nested-brackets
Created April 22, 2015 12:55
parsing nested parentheses in python, grab content by level
#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])
@constructor-igor
constructor-igor / svn-diff-bypowershell
Created December 16, 2014 12:23
How to get changes files from SVN between two revisions with PowerShell
#
# 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))
@constructor-igor
constructor-igor / powershell-problematic-excel-chart-sample
Created December 2, 2014 16:41
Problematic powershell chart sample
#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
@constructor-igor
constructor-igor / powershell-excel-chart
Created December 2, 2014 16:36
Powershell to create line chart from EXCEL
#
# 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]