Skip to content

Instantly share code, notes, and snippets.

View Konard's full-sized avatar
🖥️
Watch how I code at https://www.youtube.com/c/КонстантинДьяченко

Konstantin Dyachenko Konard

🖥️
Watch how I code at https://www.youtube.com/c/КонстантинДьяченко
View GitHub Profile
@Konard
Konard / AI Core Cycles
Created April 2, 2013 06:07
Do what you do until result is expected otherwise analyze unexpected result. (Делай то, что ты делаешь, до тех пор пока результат соответствует твоим ожиданиям. Если получен неожиданный результат - задумайся.)
using System;
namespace Console
{
class Program
{
static void Main(string[] args)
{
dynamic context = null;
Action<object> Action = (x => { return; });
@Konard
Konard / StringHelpers
Last active December 16, 2015 06:49
StringHelpers is a class, that contains GenerateRandomUTF8String function.
using System;
using System.Globalization;
using System.Linq;
namespace Konard.Helpers
{
public static class StringHelpers
{
// TODO: Исправить
//string randomString = StringHelpers.GenerateRandomUTF8String(100, UnicodeCategory.CurrencySymbol, UnicodeCategory.OtherSymbol);
@Konard
Konard / Log
Last active December 16, 2015 06:49
Log is a class that allowes easy logging to files.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Konard.Helpers
{
public class Log : IDisposable
{
@Konard
Konard / RandomExtensions.cs
Last active December 16, 2015 06:49
RandomExtensions is a container of extensions to System.Random class.
using System;
namespace Konard.Helpers
{
public static class RandomExtensions
{
public static string NextString(this Random rnd, int length)
{
if (length <= 0)
return String.Empty;
@Konard
Konard / ProcessExtensions
Created April 18, 2013 10:08
ProcessExtensions is a class that contains extension-methods for System.Diagnostics.Process class.
using System;
using System.Diagnostics;
namespace Konard.Helpers
{
public static class ProcessExtensions
{
static public void AllowDirectControlThroughParentProcess(this Process childProcess)
{
childProcess.StartInfo.UseShellExecute = false;
@Konard
Konard / ByteArrayExtensions
Last active December 16, 2015 09:18
ByteArrayExtensions is a class that contains extension-methods for System.Byte[] type.
using System;
using System.Runtime.InteropServices;
namespace Konard.Helpers
{
public static class ByteArrayExtensions
{
public static string ToRawString(this byte[] bytes)
{
if (bytes.Length <= 0)
@Konard
Konard / ThreadHelpers
Last active December 17, 2015 01:09
ThreadHelpers is a class, that contains few methods to simplify development of multithread programs.
using System;
using System.Threading;
namespace Konard.Helpers
{
public static class ThreadHelpers
{
public const int BarrierDefaultValue = int.MinValue;
public static void InitializeThreadBarrier(ref int barrier)
@Konard
Konard / ByteArrayHelpers
Last active December 17, 2015 01:10
ByteArrayHelpers is a class that contains useful methods to deal with System.Byte[] type.
using System;
using System.Runtime.InteropServices;
namespace Konard.Helpers
{
public static class ByteArrayHelpers
{
public static byte[] GetBytes<T>(T obj)
where T : struct
{
@Konard
Konard / Range
Created May 6, 2013 18:09
Range is a generic class that represents a structure based on two borders (Minimum and Maximum).
using System;
namespace Konard.Helpers
{
public struct Range<T> : IComparable<Range<T>>, IEquatable<Range<T>>
where T : IComparable<T>, IEquatable<T>
{
/// <summary>
/// Minimum value of the range
/// </summary>
@Konard
Konard / ConsoleHelpers
Created May 8, 2013 03:02
ConsoleHelpers is a class that contains utility methods for making development of console applications easier.
using System;
using System.Text;
namespace Konard.Helpers
{
public static class ConsoleHelpers
{
public static string ExtractOptionParameter(string[] args, string optionName, bool parameterIsMandatory)
{
int optionIndex = Array.IndexOf(args, "-" + optionName);