Skip to content

Instantly share code, notes, and snippets.

View yallie's full-sized avatar

Alexey Yakovlev yallie

View GitHub Profile
@yallie
yallie / Turn off Screen.bat
Last active April 1, 2023 22:58 — forked from EugeneLoy/Turn off Screen.bat
Turns off the screen and locks the workstation
@echo off
:: see https://www.makeuseof.com/tag/3-quickest-ways-turn-computer-screen-windows/
:: see https://gist.github.com/EugeneLoy/150044d04b08e35d09e164c864e78da7
powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int PostMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::PostMessage(-1,0x0112,0xF170,2)
:: see https://www.pcreview.co.uk/threads/create-a-batch-file-to-lock-computer.3747748/post-12994020
Rundll32.exe User32.dll,LockWorkStation
@yallie
yallie / test.cs
Created January 22, 2021 12:09
TcpEx: server-side connection locking issue
// http://zyan.com.de
//
// Compile using: csc test.cs /r:Zyan.Communication.dll
//
// Start up test.exe several times.
// The first process is the server, the rest are clients.
//
using System;
using System.Collections.Concurrent;
@yallie
yallie / test.cs
Last active January 21, 2021 10:42
Zyan: TcpEx global connection lock issue
// http://zyan.com.de
//
// Compile using: csc test.cs /r:Zyan.Communication.dll
//
// Start up test.exe several times.
// The first process is the server, the rest are clients.
//
using System;
using System.Collections.Concurrent;
@yallie
yallie / pascal.cs
Created October 11, 2020 16:12
Tiny Pascal parser example using Sprache.Calc
using System;
using System.Linq;
using System.Linq.Expressions;
using Mono.Linq.Expressions;
using Sprache;
using Sprache.Calc;
namespace Pascal
{
class Program
@yallie
yallie / test.cs
Last active July 1, 2020 00:20
OpenTelemetry + Jaeger. Overlapping spans demo
// Compile the code using:
// csc.exe test.cs
// /r:OpenTelemetry.Exporter.Jaeger.dll
// /r:OpenTelemetry.Api.dll
// /r:OpenTelemetry.dll
// /r:System.Diagnostics.DiagnosticSource.dll
using System;
using System.Collections.Generic;
using System.Diagnostics;
@yallie
yallie / npm-packages-in-branches.txt
Created February 6, 2020 20:47 — forked from mengstr/npm-packages-in-branches.txt
How to store npm packages in github branches
#1) Create a new repo named "my-npm" and let github initialize it with a README (screenshot below)
#2) Clone it to your computer
git clone git@github.com:SmallRoomLabs/my-npm.git
#3) Go to the clone and create a new empty branch for the first package
cd my-npm
git checkout --orphan logger
#4) Delete all files in the folder
@yallie
yallie / test.cs
Created November 27, 2019 10:24
A demonstration of the canceled subscriptions issue
// http://zyan.com.de
//
// Compile using: csc test.cs /r:Zyan.Communication.dll
//
// Start up test.exe several times.
// The first process is the server, the rest are clients.
//
using System;
using System.Collections.Concurrent;
@yallie
yallie / test.cs
Created February 15, 2019 22:23
Zyan example: two-factor authentication process
// csc test.cs /r:Zyan.Communication.dll /debug
using System;
using System.Runtime.Serialization;
using System.Security;
using System.Text;
using System.Threading;
using Zyan.Communication;
using Zyan.Communication.Protocols.Tcp;
using Zyan.Communication.Security;
@yallie
yallie / test.cs
Created October 13, 2018 20:17
Custom string class example for ApexSharp
// compile using csc.exe test.cs
using static System.Console;
namespace Apex
{
public class Program
{
static void Main()
{
String demoString1 = "Jay2";
@yallie
yallie / test.cs
Created July 19, 2017 18:43
IsServerRunning — checks whether a server is running at the specified endpoint
public static bool IsServerRunning(string url)
{
if (string.IsNullOrWhiteSpace(url))
{
throw new ArgumentNullException("url");
}
Uri uri;
try
{