Skip to content

Instantly share code, notes, and snippets.

@iarovyi
iarovyi / HTTPServer.ps1
Created December 10, 2019 08:00 — forked from jakobii/HTTPServer.ps1
A Basic Powershell Webserver
# You Should be able to Copy and Paste this into a powershell terminal and it should just work.
# To end the loop you have to kill the powershell terminal. ctrl-c wont work :/
# Http Server
$http = [System.Net.HttpListener]::new()
# Hostname and port to listen on
$http.Prefixes.Add("http://localhost:8080/")
@iarovyi
iarovyi / InstallDefaults.ps1
Last active October 10, 2019 13:41
Install base software for .NET developer
<#
.SYNOPSIS
Installs basic software for .NET developer
.PARAMETER IncludePaid
Install paied software that requires specifying license afterwards
.Example
.\InstallDefaults.ps1 -IncludePaid
#>
[CmdletBinding()]
param (
@iarovyi
iarovyi / sql-mongo_comparison.md
Created June 9, 2018 13:29 — forked from aponxi/sql-mongo_comparison.md
MongoDb Cheat Sheets

SQL to MongoDB Mapping Chart

SQL to MongoDB Mapping Chart

In addition to the charts that follow, you might want to consider the Frequently Asked Questions section for a selection of common questions about MongoDB.

Executables

The following table presents the MySQL/Oracle executables and the corresponding MongoDB executables.

<#
I) Sign executable:
.\Signing-Utilities.ps1 -CommaSeparatedFilesToSign "D:\FilesToSign\one.exe,D:\FilesToSign\two.exe"
II) Upload or update signing key:
Initialize-AWSDefaults -ProfileName !!!!!!!!!!!!!!!!! -Region eu-west-1 #Different profile for production
. .\Signing-Utilities.ps1
UploadSigningKey -SigningKeyPath "C:\Users\s.larovyi\Desktop\KMS\testKey.pfx" -Password "secret"
List of saved values: https://eu-west-1.console.aws.amazon.com/ec2/v2/home?region=eu-west-1#Parameters:sort=Name
#>
param(
[RoutePrefix("stations")]
public class RailwayStationsController : ApiController
{
[HttpGet]
[Route]
[EnableQuery]
public IQueryable<RailwayStationModel> GetAll()
{
return testData.AsQueryable();
}
@iarovyi
iarovyi / CustomTaskConsoleApplication
Created October 7, 2014 09:06
CustomTaskConsoleApplication
using System;
using System.Runtime.CompilerServices;
using System.Threading;
namespace CustomTaskConsoleApplication
{
class Program
{
static void Main(string[] args)
{
@iarovyi
iarovyi / C#_expression.cs
Last active February 13, 2020 07:28
NOTES
Expression<Func<string, bool>> f = s => s.Length < 5;
ParameterExpression p = Expression.Parameter (typeof (string), "s");
MemberExpression stringLength = Expression.Property (p, "Length");
ConstantExpression five = Expression.Constant (5);
BinaryExpression comparison = Expression.LessThan(stringLength, five);
Expression<Func<string, bool>> lambda = Expression.Lambda<Func<string, bool>> (comparison, p);
Func<string, bool> runnable = lambda.Compile();
@iarovyi
iarovyi / sandbox.cs
Created May 17, 2014 07:38
Sandbox - sandbox for plugin
string pluginFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins");
string plugInPath = Path.Combine(pluginFolder, "plugin.exe");
PermissionSet ps = new PermissionSet(PermissionState.None);
ps.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
ps.AddPermission(new FileIOPermission(FileIOPermissionAccess.PathDiscovery | FileIOPermissionAccess.Read, plugInPath));
ps.AddPermission(new UIPermission(PermissionState.Unrestricted));
AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
AppDomain sandbox = AppDomain.CreateDomain("sbox", null, setup, ps);
sandbox.ExecuteAssembly(plugInPath);
AppDomain.Unload(sandbox);
@iarovyi
iarovyi / Disassembler.cs
Created May 16, 2014 15:07
Disassembler - get MSIL as string
//http://www.albahari.com/nutshell/cs4ch18.aspx
class Disassembler
{
private static MethodBase GetCallingMethod()
{
return new StackFrame(2, false).GetMethod();
}
public static string DisassembleCurrentMethod()
{
@iarovyi
iarovyi / BitwiseMath
Last active August 29, 2015 13:57
BitwiseMath - fun with bitwise operations
using System;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
namespace SortingExtensions.Demo.Trash
{
/*
Another handy syntax