Skip to content

Instantly share code, notes, and snippets.

View Kikimora's full-sized avatar

Andrey Verbin Kikimora

View GitHub Profile
@Kikimora
Kikimora / SyncAsync.java
Last active November 28, 2023 20:52
SyncAsync.java
//Given below definitions implement MySyncApiImpl.operation and MySyncApiImpl.cancelOperation methods.
//Send me a link to github repo or a gist with your implementation.
public interface Callback {
void onSuccess(int result);
}
public interface ErrorCallback {
void onError(MyApiException error);
}
{
"swagger": "2.0",
"info": {
"title": "Payment",
"description": "## TMF API Reference : TMF 676 - Payment\n\nThis API provides the standardized client interface to Payment Systems for managing performed payments or refunds. Examples of Payment API originators (clients) include Web servers, mobile app servers, Contact center dashboards or retail store systems.",
"version": "4.0.0"
},
"host": "serverRootserverRoot",
"basePath": "/payment/v4/",
"schemes": [
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Google.Apis.Http;
using Google.Apis.Sheets.v4.Data;
using Microsoft.Extensions.Configuration;
namespace Qoden.WebSockets
{
//marketdata/info URL is a SignalR endpoint which support several 'channels'
//Book(String symbol) channel returns order book updates. Upon connecting you'll get order book snapahot and then stream of
//increments and snapshots. Snapshot is indicated by 'snapashot' flag.
//Ex: hubConnection.stream(OrderBookInfo.class, "Book", "btc_usd")
//In java version I mapped 'decimal' to String since I don't know what class in Java does same as decimal in .NET
//Trades(String symbol) channel returns recent trades. Upon connection you'll receive latest 100 trades and then you'll get updates
//as they come.
#PathBaseMiddleware не нужен!
location /bots/ {
proxy_http_version 1.1;
proxy_set_header X-Original-URI $request_uri;
#чтобы nginx стартовал даже если хост bots недоступно
set $upstream_bots bots;
# $request_uri; надо добавить чтобы nginx передавал path, даже если proxy_pass $variable.
proxy_pass http://$upstream_bots$request_uri;
//DbQueries - observabe that get all DB queries and can either pass it to Db or produce own result.
//Archive - bot orders archive service
//Archive.Save - queue order for saving
//inserts - delayed (x.Delay()) observable sequence of queries, query won't finish until Continue() is called.
[Test]
public void FinishDbWrites()
{
//arrange - start several update operations right before StopAsync
var inserts = DbQueries.Where(x => x.Command.IsInsert(BotOrderEntity.TableName)).Do(x => x.Delay());
var iter = ObservableIterator.For(inserts);
/*
* This code is an adaptation from out bot framework, I have not compiled it, use it as an illtration.
*/
/*
* This code demonstrate how to get HttpClient with authentiaction cookie. HttpClient and API refresh cookie as needed, this is completely transparent process.
*/
var cookies = new CookieContainer();
var httpClient = new HttpClient(CreateHttpHandler()) { BaseAddress = new Uri("https://trade.alt5pro.com", "frontoffice/") };
//Algebras case
//Suppose we have few expressions with Eval operation and parser in library.dll
interface IExpAgl<T>
{
T lit(int i);
T add(T x, T y);
}
public interface IEval { string Eval(); }
public class EvalAlg : IExpAgl<IEval>{}
class Parser { T Parse<T>(IExpAgl<T> a, String s); }
/Suppose we have few expressions in and parser in library.dll
interface Exp { string Eval(); }
interface IntExp : Exp {}
interface AddExp : Exp {}
public interface IParser { Exp Parse(String s); }
public class ParserImpl : IParser { Exp Parse(String s); }
public static class ParserProvider { public static IParser GetParser() => new ParserImpl(); }
//There is client.dll
public static class Client
using System;
using System.Diagnostics;
using System.Linq;
using System.Reactive;
using System.Threading.Tasks;
using FluentAssertions;
using NUnit.Framework;
using Qoden.Test.Util;
using Qoden.Validation;
using Qoden.Util;