Skip to content

Instantly share code, notes, and snippets.

View maxkoshevoi's full-sized avatar

Maksym Koshovyi maxkoshevoi

View GitHub Profile
@maxkoshevoi
maxkoshevoi / Setup.ps1
Last active December 16, 2022 04:09
Docker local environment setup
# Postgres. ConnectionString: Host=localhost;Port=5432;Database=YourDbName;Username=guest;Password=guest
docker run --name postgres -d -p 5432:5432 -e POSTGRES_PASSWORD=guest -e POSTGRES_USER=guest -e POSTGRES_DB=YourDbName -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres
# MsSQL. ConnectionString: Initial Catalog=YourDbName;Server=localhost;Persist Security Info=False;User ID=sa;Password=Guest123!;Connection Timeout=30;
docker run --name mssql -d -p 1433:1433 -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=Guest123!' -v sqlvolume:/var/opt/mssql mcr.microsoft.com/mssql/server:2019-latest
# RabbitMQ for MassTransit. ConnectionString: amqp://localhost:5672. Management portal: localhost:15672 (login and password: guest)
docker run --name rabbitmq -d -p 15672:15672 -p 5672:5672 masstransit/rabbitmq
@maxkoshevoi
maxkoshevoi / download-latest-release.ps1
Created April 9, 2021 18:05
Download latest GitHub release via Powershell
$repoName = "PowerShell/PowerShell"
$assetPattern = "*-win-x64.msi"
$extractDirectory = "C:\Users\Public\Downloads"
$releasesUri = "https://api.github.com/repos/$repoName/releases/latest"
$asset = (Invoke-WebRequest $releasesUri | ConvertFrom-Json).assets | Where-Object name -like $assetPattern
$downloadUri = $asset.browser_download_url
$extractPath = [System.IO.Path]::Combine($extractDirectory, $asset.name)
@maxkoshevoi
maxkoshevoi / MonitorBrightness.cs
Created April 25, 2020 10:23
Change screen brightness
using System;
using System.Management;
public static class MonitorBrightness
{
public static int Get()
{
using var mclass = new ManagementClass("WmiMonitorBrightness")
{
Scope = new ManagementScope(@"\\.\root\wmi")
@maxkoshevoi
maxkoshevoi / WinForms_Invoke.cs
Last active January 11, 2024 20:34
Simplest way to update UI from another thread in WinForms
myControl.Invoke((Action)delegate
{
myControl.Enabled = true;
});
// More correct way
public static class ControlEx
{
public static void Invoke(this Control control, MethodInvoker action)
{
@maxkoshevoi
maxkoshevoi / get_dart_lint_config.ps1
Created October 31, 2019 20:46
Download lint config for Dart
iwr -outf analysis_options.yaml https://raw.githubusercontent.com/flutter/flutter/master/analysis_options.yaml
@maxkoshevoi
maxkoshevoi / create_certificate.ps1
Created October 18, 2019 16:21
Creates and installs certificate with manual "Issued by" and "Issued to"
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
$filepath = $MyInvocation.MyCommand.Path
$dirpath = Split-Path $filepath
$cred = Get-Credential -UserName 'localhost' -Message "$('Enter site name and password for certificate below')"; $site = $cred.UserName; $pwd = $cred.Password #this will open prompt to enter a password manually
#$site = 'localhost'; $pwd = ConvertTo-SecureString -String "1" -Force -AsPlainText #1 is password for certificate
if ($pwd -and $site){
$cert = New-SelfSignedCertificate -Type Custom -Subject "CN=dev_cert" -CertStoreLocation cert:\localmachine\my -DnsName $site -KeyUsage DataEncipherment -KeyUsageProperty All -KeyAlgorithm RSA -KeyLength 2048 -NotAfter (Get-Date).AddYears(3)
$name = $cert.PSChildName
@maxkoshevoi
maxkoshevoi / Ftp.cs
Created October 13, 2019 22:23
Working with FTP using .Net
using System;
using System.IO;
using System.Net;
class Ftp
{
private readonly string server, login, password;
public Ftp(string server, string login, string password)
{
@maxkoshevoi
maxkoshevoi / Email.cs
Last active December 16, 2022 04:09
Sending Email using .Net
using System.Net.Mail;
static class Mail
{
public static void Send(string to, string subject, string content)
{
var mail = new MailMessage("INSERT FROM EMAIL HERE", to)
{
Subject = subject,
Body = content
@maxkoshevoi
maxkoshevoi / YouTube_channels.md
Last active March 28, 2022 12:11
Awesome YouTube channels

3Blue1Brown - Интересные штуки, связанные с математикой

ADVChina - Два парня из Америки, живут в Китае, и рассказывают о его особенностях

AlternateHistoryHub – Рассказывает про исторические события и что было бы, если бы их не было

CGP Grey, LEMMiNO, ApertureAperture, Brew (этот с кофе) – Очень классный канал научно-познавательный канал (сложно описать, но стоит посмотреть)

Epic How To – Как стать Бетменом? Сымитировать свою смерть? Стать шпионом? Создать свою страну? Это и не только в этом плейлисте

@maxkoshevoi
maxkoshevoi / SearchTextInSP.sql
Created October 9, 2019 20:14
Search for text inside every stored procedure of MSSQL database
SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
select distinct
so.[xtype],
so.[id],
so.[name],
po.[name]
from sysobjects so
left join sysobjects po