Skip to content

Instantly share code, notes, and snippets.

Avatar
🤖
creating new things

Viacheslav Avsenev snmslavk

🤖
creating new things
View GitHub Profile
View ChartObject.cs
using System.Collections.Generic;
namespace DigitalFuture.Intranet.Models.Analytics
{
public class ChartObject
{
public int totalRecordCount { get; set; }
public string timeResolution { get; set; }
public List<object> messages { get; set; }
public Data data { get; set; }
View asdf.sh
/tmp/WindowsService1.exe
/tmp/WindowsService1.exe.config
View gist:ccb798aabe9f6b7a44717931426d4e61
using System;
using System.ServiceProcess;
namespace WindowsService1
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
View JS add trim functionality to the string
if(typeof String.prototype.trim !== 'function') {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
}
}
@snmslavk
snmslavk / AsyncSample.cs
Created Apr 22, 2016
Different usage of Aync in C#
View AsyncSample.cs
public class MegaClass
{
public async void StartAsync()
{
await Task.Run(() => { LongProcedure(); });
Console.WriteLine("End");
}
public void Start()
{
View ZipFuncs.cs
using System.Collections.Generic;
using System.IO;
namespace ZipLib
{
public class ZipFuncs
{
public static byte[] CreateZipArhive(List<string> _pathin)
{
if ((_pathin ?? new List<string>()).Count > 0)
@snmslavk
snmslavk / ExeFileModel.cs
Created Apr 7, 2016
Start banch of files every day at specific time
View ExeFileModel.cs
using System;
namespace RunFileLib
{
public class ExeFileModel
{
public ExeFileModel()
{
LastStart = DateTime.Now.AddDays(-1);
}
@snmslavk
snmslavk / EventsDelegates.cs
Last active Apr 6, 2016
Events and delegates
View EventsDelegates.cs
public class SampleEventArgs
{
public SampleEventArgs(string s) { Text = s; }
public String Text { get; private set; } // readonly
}
public class Publisher
{
//Sample delegate
public delegate void SampleEventHandler(object sender, SampleEventArgs e);
//GenericDelegate
@snmslavk
snmslavk / CheckXmlViaXsd.cs
Last active Apr 6, 2016
Validate XML against XSD
View CheckXmlViaXsd.cs
public class XSDRoutine
{
public static void Check(string pathXsd,string pathXml)
{
XmlSchemaSet sc = new XmlSchemaSet();
sc.Add("", pathXsd);
XmlReaderSettings settings = new XmlReaderSettings()
{
@snmslavk
snmslavk / SynchronizedCache.cs
Created Mar 16, 2016
Custom Synchronized Cache
View SynchronizedCache.cs
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading;
namespace TestCustomCache
{
public sealed class CacheSingleton
{
private static readonly SynchronizedCache instance = new SynchronizedCache();