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 / gist:7397076
Created November 10, 2013 11:30
how to get executable version
public static string Version
{
get
{
Assembly asm = Assembly.GetExecutingAssembly();
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(asm.Location);
return String.Format("{0}.{1}.{2}.{3}", fvi.ProductMajorPart, fvi.ProductMinorPart, fvi.ProductBuildPart, fvi.ProductPrivatePart);
}
}
@constructor-igor
constructor-igor / gist:7412423
Created November 11, 2013 12:24
how to copy directory
private static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs)
{
// Get the subdirectories for the specified directory.
DirectoryInfo dir = new DirectoryInfo(sourceDirName);
DirectoryInfo[] dirs = dir.GetDirectories();
if (!dir.Exists)
{
throw new DirectoryNotFoundException(
"Source directory does not exist or could not be found: "
@constructor-igor
constructor-igor / gist:7578986
Created November 21, 2013 10:02
Get DLL names from running process, possible?
Process[] processes = Process.GetProcesses();
foreach(Process process in processes) {
Console.WriteLine("PID: " + process.Id);
Console.WriteLine("Name: " + process.Name);
Console.WriteLine("Modules:");
foreach(ProcessModule module in process.Modules) {
Console.WriteLine(module.FileName);
}
@constructor-igor
constructor-igor / gist:7746536
Last active December 29, 2015 23:59
how to open folder in Windows Explorer
Process.Start("explorer.exe", "/select," + <folder>);
@constructor-igor
constructor-igor / sending-email-via-Outlook-sample
Created November 24, 2014 13:21
Sending email via Outlook (powershell)
$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)
$Mail.To = "[email protected]"
$Mail.Subject = "Action"
$Mail.Body ="Pay rise please"
$Mail.Send()
@constructor-igor
constructor-igor / create-msqueue-and-send-message
Last active August 29, 2015 14:10
create-msqueue-send-message-and-receive-message (powershell)
#
#
# References:
# http://ardalis.com/How-Can-I-View-MSMQ-Messages-and-Queues
# to see queue, search via "Computer Mamagment"
#
# simular sample: http://blogs.msdn.com/b/sajay/archive/2010/03/18/powershell-script-to-create-an-msmq.aspx
#
[Reflection.Assembly]::LoadWithPartialName("System.Messaging")
@constructor-igor
constructor-igor / create-zip-file-powershell
Last active August 29, 2015 14:10
create Zip file (powershell)
#
# http://stackoverflow.com/questions/1153126/how-to-create-a-zip-archive-with-powershell
#
#
# $zipFileName contains path to new .zip file
# $sourceDir contains path to folder with source data
#
ZipFiles $zipFileName $sourceDir
@constructor-igor
constructor-igor / include-simulation-in-powershell
Created November 25, 2014 11:32
Include simulation in powershell
. "$PSScriptRoot\genericFunctions.ps1"
#
#
#
<actual powershell source, can use functions from file genericFunction.ps1>
@constructor-igor
constructor-igor / powershell-send-email-via-Outlook-and-insert-image-to-body
Last active September 5, 2018 17:55
Powershell: send email via Outlook and insert image to body
function SendEmailWithEmbeddedImage([String] $to, [String] $subject, [String] $body, [String] $attachment, [String] $imageFile)
{
#$htmlHeader = "<HEAD>Text<B>BOLD</B> <span style='color:#E36C0A'>Color Text</span></HEAD>"
$htmlText = "<HTML>{0}</HTML><img src='cid:{1}'>"
$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)
$Mail.To = $to #"[email protected]"
$Mail.Subject = $subject
$Mail.HTMLBody = [string]::Format($htmlText, $body, ExtractFileName $imageFile)
@constructor-igor
constructor-igor / gist:18e88b456833f3dc9d7f
Created November 26, 2014 13:00
powershell: google chart api sample (small numbers, scaling)
#
# sample:
#$title = "MyChart"
#$size = "700x350"
#$url = CreateChartUrl $valueArray $labelArray $title $size
#
function CreateChartUrl ($valueArray, $labelArray, [string]$title, $size) {
$chartType = "lc"
$chartData = [string]::join(",", $valueArray)