Skip to content

Instantly share code, notes, and snippets.

View Hereigo's full-sized avatar

Hereigo Hereigo

  • Ukraine, Kyiv
View GitHub Profile
@Hereigo
Hereigo / WebApiOwinBased.cs
Last active May 30, 2017 09:33
.Net - Owin based WebAPI with Logger-module
// 1. Install-Package Microsoft.AspNet.WebApi.Owin
// 2. Install-Package Microsoft.Owin.Host.SystemWeb
//
public class Startup
{
public void Configuration(IAppBuilder appBld)
{
// Possible to define DEFAULT action-module:
appBld.Properties["builder.DefaultApp"] = new AppFunc( env =>
{
@Hereigo
Hereigo / WCF_ExceptionsHandling.cs
Last active May 26, 2017 07:06
.Net - WCF Service Exceptions Handling
[ServiceContract]
public interface IMyServiceContract
{
[OperationContract]
[FaultContract(typeof(FaultException))]
string OperationAndFaultContract(int a);
}
//===========================================
public class MyServiceContract : IMyServiceContract
@Hereigo
Hereigo / 7z_Bkp.cmd
Created May 23, 2017 08:23
.Cmd - 7z Back Up my profile
@SETLOCAL
@SET now=%DATE:~0,2%
@SET /a nowmod2=now %% 2
@IF %now% == 28 ( SET suffix=%now%) ELSE IF %nowmod2% == 0 ( SET suffix=Even ) ELSE ( SET suffix=Odd )
@"C:\Program Files\7-Zip\7z.exe" a -spf -ssw -x!*.log -r "%USERPROFILE%\Bkps\PFL_BKP_%suffix%.zip" "%USERPROFILE%\Desktop\*"
@ECHO .
@ECHO Today is - %now%
@ECHO .
@ECHO Bkp-suffix is - %suffix%
PAUSE
@Hereigo
Hereigo / GetInfoAboutAllAssemblies.cs
Last active May 13, 2017 13:33
.Net - Get Info About All Assemblies in the Solution.
class Csproj_Config_Files_Parse_
{
void GetInfoAboutAllAssemblies()
{
string rootDir = @"c:\Bla-Bla-Bla... Path To Solution Directory";
string rezFile = @"c:\Bla-Bla-Bla... Path To REZULT_FILE.txt";
try
{
@Hereigo
Hereigo / WCF_Example.cs
Created May 8, 2017 17:53
.Net - WCF Example
using System.ServiceModel;
using System.ServiceModel.Description;
[ServiceContract]
interface Interface1
{
[OperationContract]
int Sum(int a, int b);
}
@Hereigo
Hereigo / ShowLastLines.ps1
Last active November 24, 2017 08:42
Ps1 - Show Files Last Lines Without Empty Lines
$currPath = $MyInvocation.MyCommand.Path
$logFiles = Get-ChildItem $currPath | where { $_.extension -eq ".log" }
# Read & show last 10 lines of every log-file (exclude empty lines)
foreach ($file in $logFiles) {
Echo "-----------------------------------------";
"";
Echo $file.ToString().ToUpper(); # FileName as Header.
"";
@Hereigo
Hereigo / AsyncCallback_Return.cs
Created April 11, 2017 06:26
.Net - AsyncDelegate for AsyncCallback
public class IAsyncResultClass
{
Func<int, int, int> deleg = new Func<int, int, int>(MyAsyncMeth);
private static int MyAsyncMeth(int a, int b)
{
for (int i = 0; i < 4; i++)
{
Console.Write("MyAsyncMeth");
System.Threading.Thread.Sleep(1500);
@Hereigo
Hereigo / AsyncCallback.cs
Created April 11, 2017 06:08
.Net - AsyncCallback
public class IAsyncResultClass
{
Action deleg = new Action(MyAsyncMeth);
private static void MyAsyncMeth()
{
for (int i = 0; i < 4; i++)
{
Console.Write("MyAsyncMeth");
System.Threading.Thread.Sleep(1500);
@Hereigo
Hereigo / MyTime_EventHandler_Logger.cs
Last active April 7, 2017 15:11
.Net - MyTime_EventHandler_Logger.cs
using Microsoft.Win32;
using System;
using System.Data;
using System.Data.Common;
using System.Data.SQLite;
using System.IO;
namespace SQLight_Test
{
class Program
@Hereigo
Hereigo / SessionLock_Unlock_Events.cs
Created April 7, 2017 13:07
.Net - SessionLock & SessionUnlock Events
using Microsoft.Win32;
class Program
{
private static SessionSwitchEventHandler sseh;
static void Main(string[] args)
{
try
{