Skip to content

Instantly share code, notes, and snippets.

import MetaApi from 'metaapi.cloud-sdk';
import { Order } from './types/Order';
import { PnL } from './types/PnL';
import { Position } from './types/Position';
import { error, log } from './logging';
import { ConditionalOrderProps, IBroker, SubmitFuturesOrderProps } from './IBroker';
import { MetatraderAccount, RpcMetaApiConnectionInstance } from 'metaapi.cloud-sdk';
export class MetaAPIBroker implements IBroker {
private api: MetaApi;
import * as MediaLibrary from "expo-media-library";
// download a sample mp4 file from here https://test-videos.co.uk/bigbuckbunny/mp4-h264
const url = "file:///Users/[username]/Downloads/bigbuckbunny.mp4"
await MediaLibrary.saveToLibraryAsync(url);
// throws an error `This file type is not supported yet`
`
You are assisting the user to generate a video of their trip. Follow these instructions to guide the user in providing details about the trip and the video preferences.
This chat can open a window with some predefined answers or actions.
Use ${SHOW_DIALOG} tool to show dialog windows to the user. The parameter window_name defines which window to show.
Use ${SAVE_TRIP_DETAILS_TOOL} tool to save the trip details once the user confirms the trip.
Use ${SAVE_ORIENTATION_TOOL} tool to save the orientation once the user provides it.
<Instructions>
@zallesov
zallesov / Types Zoo
Created February 17, 2024 22:19
Code snippet for medium article
import { DateTime } from 'luxon';
import { z } from 'zod';
/**
* Replace type V1 with type V2.
*/
type Replace<T, V1, V2> = T extends V1 ? V2 : never;
/**
* Replace all fields of type V1 with fields of type V2.
static Color biasedColor(Color color, float offset){
float value = (color.r + color.g + color.b) / 3.0;
float newValue = value+2.0*((float)random(0,10000)/10000.0)*offset-offset;
float valueRatio = newValue / value;
int R = (int)((float)color.r * valueRatio);
int G = (int)((float)color.g * valueRatio);
int B = (int)((float)color.b * valueRatio);
return Color(R,G,B);
}
#ifndef __TIMER_GUARD__
#define __TIMER_GUARD__
class TimeGuard {
private:
unsigned long lastUpdated = 0;
unsigned long interval;
public:
import java.io._
import Main.file
import scala.collection.mutable
import scala.util.Random
object Main extends App {
val randomFileName = "random.txt"