Skip to content

Instantly share code, notes, and snippets.

View ArseniySavin's full-sized avatar
😏

savars ArseniySavin

😏
View GitHub Profile
@ArseniySavin
ArseniySavin / publicating-go-application-on-github.md
Last active February 21, 2021 04:45 — forked from lesovsky/publicating-go-application-on-github.md
Publicating Golang application on GitHub.

Link

Publicating Golang application on GitHub.

  • Makefile
  • Dockerfile
  • Github Actions
  • Goreleaser

Makefile

@ArseniySavin
ArseniySavin / FirstFrame_ffmpeg.go
Last active May 29, 2022 14:13
Getting first frame used ffmpeg. Read / Write into stdin /stdout
func FirstFrame(path string, data []byte) (*bufio.Reader, error) {
cmd := exec.Command(path,
"-i", "-", // read from stdin
"-vframes", fmt.Sprint(1), // frame
"-s", fmt.Sprintf("%dx%d", 640, 360), // size
"-q:v", fmt.Sprint(2), // quality
"-f", "singlejpeg", // jpeg binary
"-", // read from stdout
)
// stdin read
public class SomeClass {
public void SomeMethod() {
this.Log().Info(() => "Here is a log message with params which can be in Razor Views as well: '{0}'".FormatWith(typeof(SomeClass).Name));
}
}
@ArseniySavin
ArseniySavin / BinarySerialaizer.cs
Last active December 6, 2019 12:50
Binary serialize extension
public class BinaryModelSerialaizer
{
BinaryFormatter _binaryFormatter;
public BinaryModelSerialaizer(BinaryFormatter binaryFormatter)
{
_binaryFormatter = binaryFormatter;
}
public byte[] Serialize<T>(T obj)
@ArseniySavin
ArseniySavin / ActivityIdHeader.xml
Created August 27, 2019 06:15
Adding the ActivityId into soap header at call service
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bis="http://Test/B.Info">
<soapenv:Header>
<ActivityId xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">00000000-0000-0000-0000-201908271035</ActivityId>
</soapenv:Header>
<soapenv:Body>
<bis:TryGetInfo>
<bis:hash>
<string>447F76CBD3B5AE0FABFDCF065B5BFC461C9E7E42</string>
</bis:hash>
</bis:TryGetInfo>
@ArseniySavin
ArseniySavin / query_plan.sql
Created August 26, 2019 02:44
Top higher exception statements
SELECT TOP 10 substring(t.TEXT, qs.statement_start_offset / 2, CASE
WHEN qs.statement_end_offset = - 1
THEN len(t.TEXT)
ELSE (qs.statement_end_offset - qs.statement_start_offset) / 2
END)
,qs.execution_count
,cast(qs.total_worker_time / 1000 AS DECIMAL(18, 2)) AS total_worker_time_ms
,cast(qs.total_worker_time * 1. / qs.execution_count / 1000. AS DECIMAL(18, 2)) AS avg_worker_time_ms
,cast(p.query_plan AS XML) AS query_plan
FROM sys.dm_exec_query_stats qs
@ArseniySavin
ArseniySavin / SearchObjectByAllTables.sql
Created June 3, 2019 08:51
MSSQL search object by all tables
set nocount on
declare @name varchar(128), @substr nvarchar(4000), @column varchar(128)
set @substr = '%%' --фрагмент строки, который будем искать
create table #rslt
(table_name varchar(128), field_name varchar(128), value ntext)
declare s cursor for select table_name as table_name from information_schema.tables where table_type = 'BASE TABLE' order by table_name
open s
fetch next from s into @name
@ArseniySavin
ArseniySavin / machine.config
Last active February 4, 2025 15:28
Tuning .NET Application Performance and IIS
<!--
Path: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config
Description: The setting calculate using this article https://docs.microsoft.com/en-us/previous-versions/msp-n-p/ff647813(v=pandp.10)
The values set out of youre hardware.
Example for hardware: CPU 4 Core, RAM 8 Gb
-->
<system.web>
<!--<processModel autoConfig="true" />-->
<processModel autoConfig="False" maxWorkerThreads="1000" maxIoThreads="1000" minWorkerThreads="1000" minIoThreads="1000" />
<httpRuntime appRequestQueueLimit="50000" minFreeThreads="999" minLocalRequestFreeThreads="999"/>
{
"RouteInfo": {
"InstanceId": "GUID",
"ParentInstanceId": "GUID",
"RouteType": "String",
"RouteCode": "String"
},
"Correlation": [ // Какието ID запесей в очереди базы, которые нужно ожидать пока они исполнятся
{
"Id": "1",
class Program
{
static void Main(string[] args)
{
RootMenu rootMenu = new RootMenu();
CategoryMenu category1 = new CategoryMenu { CategoryId = 1, Name = "telecom", Alias = "telecom-internet" };
category1.Add(new Service { ServiceId = 1, Alias = "mobile-altel", Name = "Altel", RegionName = "ALM" });