Skip to content

Instantly share code, notes, and snippets.

View mstefarov's full-sized avatar

Matvei Stefarov mstefarov

View GitHub Profile
[MediumRunJob]
[MemoryDiagnoser]
public class StringDictBench
{
System.Collections.Generic.Dictionary<ReadOnlyMemory<char>, string> mem = new();
System.Collections.Generic.Dictionary<string, string> str = new();
string key = "key";
public StringDictBench()
{
[MediumRunJob]
[MemoryDiagnoser]
public class ToTest
{
Dictionary<string,IntPtr> stringKeys = new();
Dictionary<TileKey,IntPtr> structKeys = new();
public ToTest()
{
for (int x = -4; x < 5; x++)
@mstefarov
mstefarov / ReplaceCrs84WithEpsg4326.cs
Last active May 1, 2018 00:17
Example how ArcGISHttpClientHandler.HttpRequestBegin event can be used to rewrite WMS requests.
private static void ReplaceCrs84WithEpsg4326(object sender, HttpRequestMessage e)
{
string rawQuery = e.RequestUri.Query;
// Skip requests without a query
if (string.IsNullOrEmpty(rawQuery))
return;
// For convenience, parse query as a Dictionary
var queryParameters = System.Web.HttpUtility.ParseQueryString(rawQuery);
// Redirects requests to a given file
class FileBasedHttpResponder : HttpClientHandler
{
private readonly FileInfo _targetFileInfo;
public FileBasedHttpResponder(string targetPath)
{
_targetFileInfo = new FileInfo(targetPath);
}
public static void takeVote()
{
World[] voteWorlds = PropHuntWorlds.OrderBy(x => randWorld.Next())
.Take(3)
.ToArray();
NewVote();
Server.Players.Message("&S--------------------------------------------------------------");
Server.Players.Message("Vote for the next map!");
Server.Players.Message("&S/Vote &c1&S for {0}&S, &c2&S for {1}&S, and &c3&S for {2}",
// step 1: find index of largest value
// If there is a tie, the last of the tied worlds will be chosen
World chosenWorld;
int maxVotes = int.MinValue, i = 0;
foreach (int votes in voteList) {
if ((chosenWorld == null) || (votes > maxVotes)) {
maxVotes = votes;
chosenWorld = worldList[i];
}
i++;
public static void main(String[] args) { //1. main method. In the main program declare a Scanner variable that is hooked up to System.in.
//You need to include the line of code import java.util.Scanner; at the top of your program. Pass the Scanner object you create as a
//parameter to any methods that need it.
//The main method should not have a lot of statements, instead it shall call other methods.
RockPaperScissors();
}
public static void RockPaperScissors() {
System.out.println("Welcome to Rock Paper Scissors. I, Computer, will be your opponent.");
using System;
using System.Collections;
using System.Collections.Generic;
using JetBrains.Annotations;
namespace fCraft {
public class BitMap3D : IEnumerable<Vector3I> {
const int BitCoordMask = 31;
readonly uint[] store;
using System;
using System.Collections;
using System.Collections.Generic;
using JetBrains.Annotations;
namespace fCraft {
public class BitMap3D : IEnumerable<Vector3I> {
const int BitCoordMask = 31;
readonly uint[] store;
@mstefarov
mstefarov / test.cs
Last active December 16, 2015 06:39 — forked from anonymous/test.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BucketSort
{
class Program
{