This file contains 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 Data | |
{ | |
[Serializable] | |
public class OrderedList<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary | |
{ |
This file contains 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
[Test] | |
public void CursorShouldGetLessOrEqual() { | |
_db = _txn.OpenDatabase(flags: DbFlags.None); | |
var db2 = _txn.OpenDatabase("test_le", | |
DbFlags.Create | DbFlags.IntegerKey); | |
using (var cur = _txn.CreateCursor(db2)) { | |
int[] keys = new int[10000000]; |
This file contains 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
namespace Test | |
open System | |
open System.Linq | |
open System.Linq.Expressions | |
//thanks to http://v2matveev.blogspot.ru/2010/06/f-performance-of-events.html | |
// helper type that will perform invocation | |
type internal Invoker<'D, 'A> = delegate of 'D * obj * 'A -> unit |
This file contains 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
RLSF <- function(y,x,alpha=0.95,ist=30,xpxi=NULL,xpy0=NULL) | |
{ | |
# http://queue.acm.org/detail.cfm?id=2534976 | |
if(!is.matrix(x))x=as.matrix(x) | |
nT=dim(x)[1] | |
k=dim(x)[2] | |
xpx0 = NULL | |
# | |
if(is.null(xpxi)){ | |
if(ist <= k)ist=k+1 |
This file contains 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.Net.WebSockets; | |
var wsc = new ClientWebSocket(); | |
await wsc.ConnectAsync(new Uri("wss://ws-feed.gdax.com"), CancellationToken.None); | |
Console.WriteLine("Connected..."); | |
var msg = @"{""type"": ""subscribe"", ""product_ids"": [""BTC-USD"", ""ETH-USD"", ""ETH-BTC""]}"; | |
Console.WriteLine(msg); | |
await wsc.SendAsync(new ArraySegment<byte>(Encoding.UTF8.GetBytes(msg)), WebSocketMessageType.Text, true, CancellationToken.None); | |
var buffer = new ArraySegment<byte>(new byte[4096]); | |
while (true) | |
{ |
This file contains 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
let sum = (x?: number) => { | |
// the trick is to access inner from inside itself as `any` with `.sum` initialized to 0 | |
// we know that the reference will be initialized | |
// we could certainly achieve the same effect by using `this.` | |
// but scoping with `this` is not intuitive | |
let inner; | |
inner = (x1?: number) => { | |
// need additional check for 0, e.g. calling sum(0)(1)(0)() is valid, same below | |
if (x1 || x1 === 0) { |
This file contains 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
{ | |
// Place your snippets for typescript here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
// "Print to console": { | |
// "prefix": "log", | |
// "body": [ | |
// "console.log('$1');", |
This file contains 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.Generic; | |
using System.Threading.Tasks; | |
namespace MemoryPressure | |
{ | |
internal class Program | |
{ | |
private static List<byte[]> _buffers = new List<byte[]>(); |
This file contains 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
[StructLayout(LayoutKind.Sequential, Size = Size)] | |
public struct Test | |
{ | |
public const int Size = 32; | |
public byte this[int idx] => Unsafe.AddByteOffset(ref Unsafe.As<Test, byte>(ref Unsafe.AsRef(in this)), (IntPtr)idx); | |
public override string ToString() | |
{ | |
Span<byte> bytes = stackalloc byte[Size]; | |
for (int i = 0; i < Size; i++) |
This file contains 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
// Licensed to the .NET Foundation under one or more agreements. | |
// The .NET Foundation licenses this file to you under the MIT license. | |
// See the LICENSE file in the project root for more information. | |
using System.Diagnostics; | |
using System.Runtime.ExceptionServices; | |
using System.Runtime.InteropServices; | |
namespace System.Threading.Tasks.Sources |
OlderNewer