This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class VarInt { | |
public static bool TryRead(ReadOnlySpan < byte > slice, out int value, out int readBytes) { | |
readBytes = 0; | |
value = 0; | |
var shift = 0; | |
while (true) { | |
if (readBytes >= slice.Length) | |
return false; | |
var nextByte = slice[readBytes++]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
BenchmarkRunner.Run<BenchmarkArraySplit>(); | |
[MemoryDiagnoser] | |
public class BenchmarkArraySplit | |
{ | |
[Benchmark] | |
public string Vabka() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// And same for IQueryable | |
public static class EnumerableExtensions | |
{ | |
public static T? SingleOrNull<T>(this IEnumerable<T> seq, Func<T, bool> predicate) where T : struct | |
{ | |
var data = seq.Where(predicate).Take(2).ToArray(); | |
if (data.Length == 2) | |
throw new InvalidOperationException(); | |
if (data.Length == 0) | |
return null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function helloWorld() { | |
return "hello" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ExhangeRatesAPI.Service | |
open ExhangeRatesAPI.Types | |
open ExhangeRatesAPI.Common | |
type Rate = | |
{ Left: Symbol | |
Right: Symbol | |
Value: decimal } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class CalendarDate { | |
private readonly date: Date; | |
constructor(date: Date) { | |
this.date = new Date(date); | |
} | |
public static today(): CalendarDate { | |
return new CalendarDate(new Date()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Container<T> = Readonly<{ value: T, pipe<U>(f: (value: T) => U): Container<T> }>; | |
class PersistentContainer<T> implements Container<T> { | |
private readonly _value: T; | |
public get value() { | |
return this._value; | |
} | |
constructor(value: T) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace _ | |
{ | |
public sealed class Tree<TKey, TValue> : IEnumerable<KeyValuePair<TKey, Tree<TKey, TValue>.Node>> | |
where TKey : IEquatable<TKey> | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Threading.Tasks; | |
using PuppeteerSharp; | |
namespace pptrTest | |
{ | |
class Program | |
{ | |
static async Task Main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use actix_web::web::Json; | |
use actix_web::{get, App, HttpServer, Result}; | |
use chrono::prelude::*; | |
use log::LevelFilter; | |
use serde::Serialize; | |
use std::io; | |
fn main() -> Result<(), io::Error> { | |
env_logger::builder().filter_level(LevelFilter::Info).init(); | |
let service = HttpServer::new(|| App::new().service(today)) |
NewerOlder