Skip to content

Instantly share code, notes, and snippets.

@glebov21
glebov21 / monitrc
Last active March 3, 2021 14:54
monit config
###############################################################################
## Monit control file
###############################################################################
##
## Comments begin with a '#' and extend through the end of the line. Keywords
## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
##
## Below you will find examples of some frequently used statements. For
## information about the control file and a complete list of statements and
## options, please have a look in the Monit manual.
Trace.AutoFlush = true;
var logFileName = "Log" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + ".txt";
var logFilePath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), logFileName);
var _logFileStream = new FileStream(logFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, 4096, FileOptions.Asynchronous);
var _streamWriter = new StreamWriter(_logFileStream);
Trace.Listeners.Add(new TextWriterTraceListener(_streamWriter));
public abstract class AsyncOperationBase<TResult, TError>
{
public UInt32 Id { get; private set; }
AsyncOpStatus Status { get; private set; }
TError Error { get; private set; }
public void Cancel();
public event Action<AsyncOpStatus> OnCompleted = delegate {};
public event Action<float> OnProgress = delegate {};
private void SetResult(TResult result)
@glebov21
glebov21 / gist:4bef871344516b230c03674c899978ca
Last active February 18, 2019 07:59
Исправление Windows forms разные dpi
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool SetProcessDPIAware();
//rf
@glebov21
glebov21 / Run.bat
Created September 26, 2018 07:54
Run c# from bat
@ECHO off
Echo Please run as administrator
setlocal
cd /d %~dp0
set csDir=%cd%\Program.cs
powershell ^
set-executionpolicy remotesigned; ^
$source = Get-Content -Raw -Path %csDir%; ^
Add-Type -TypeDefinition "$source"; ^
[Program]::Main()
@glebov21
glebov21 / Validator
Created September 11, 2018 12:44
Validator
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using TMPro;
using UnityEditor;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
@glebov21
glebov21 / ScriptableObjectCreator.cs
Last active September 19, 2018 08:09
ScriptableObjectCreator
using System.IO;
using UnityEditor;
using UnityEngine;
namespace Autogramma.CombApp.Editor
{
public class ScriptableObjectCreator
{
[MenuItem("Assets/Create/SO")]
public static void CreateAsset()
@glebov21
glebov21 / ScriptableObjectUtility.cs
Last active September 19, 2018 08:09
ScriptableObjectUtility
using UnityEngine;
using UnityEditor;
public static class ScriptableObjectUtility
{
/// <summary>
// This makes it easy to create, name and place unique new ScriptableObject asset files.
/// </summary>
public static T CreateAsset<T>(string path, string name = null) where T : ScriptableObject
{
@glebov21
glebov21 / CodeHelpers
Created September 6, 2018 14:46
CodeHelpers
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using System.Xml.Serialization;
@glebov21
glebov21 / ILMerge
Last active September 6, 2018 13:48
ILMerge
if $(ConfigurationName) == Release (
"C:\Program Files (x86)\Microsoft\ILMerge\ILMerge.exe" /ndebug /target:winexe /out:$(TargetDir)$(TargetName)1$(TargetExt) $(TargetPath) $(TargetDir)DotNetZip.dll /targetplatform:v2,C:\Windows\Microsoft.NET\Framework\v2.0.50727
del $(TargetPath) /Q /S
del $(TargetDir)DotNetZip.dll /Q /S
del $(TargetDir)DotNetZip.xml /Q /S
rename "$(TargetDir)$(TargetName)1$(TargetExt)" "$(TargetFileName)"
)