Skip to content

Instantly share code, notes, and snippets.

@Pzixel
Pzixel / Factorio.txt
Created March 13, 2021 16:30
Factorio
Hello
@Pzixel
Pzixel / Cargo.toml
Last active March 6, 2021 14:12
Mongodb test
[package]
name = "mongodb-test"
version = "0.1.0"
authors = ["Psilon <[email protected]>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tokio = { version = "0.2", features = ["macros"] }
0eNq9XduOHFdy/BVjnjnGuWSei579FwvB4KVNDkwOibloLSz2311NWp6zUldXZAQ4T7uSyMo+mRnZ1VWREf+4eff5+fTt4e7+6eaXf9zcvf96/3jzy9/+cfN49/H+7efzv3v6/dvp5pebu6fTl5s3N/dvv5z/6d3p7fZHb/755ubu/sPpf25+yf98c/iXPn/9++2H0/3j3dPvt49PD8/vn54fTss1yj9/fXNzun+6e7o7/fgU3//h9/+8f/7y7vSwBflz/Dc3375ul7vb/u8WdLtE7fXf/c3N7ze/3Hb7dz9fe/sIj+f/+vjtdPpw++Xrh+fPp9t6jnb+yH+KUIAITYpQjyOMJEUwIIKWJQciaFlqxxGmlqUORNCyNIAIWpbmYQRLWpZyAkJoacoZCKHlKR/D2rKYqAqEEBNlQAgxUcfItiImqgEhxER1IISYqGNwWxUTBaC7it92ALqrlqgCoNu0RBUA3SYmCkC3iYkC0O1iogB0u5goAN0uJgpAdxMTBaC7iYkC0N3EO00A3V1LVAXQLd6RVwDd6i05gG7xnrwC6BZvyiuAbvGuvALoFm/LK4Bu8b68vqD79D/fHk6Pj7fP2w/Qh48PX7f/vX13+vx06Wdf/v+g5XvQD3cPp/c//sTWon/84L3/9vx0cynoDP12zczvvkSdqyPn+vr8tHMwy3+J+vTw9v7x29eHp92Y80rMSzEKEWMEY9R4jGUoYDGMqdDQOs889DyA6rxGnUvtvE5ULNp5g4gR7bzJZG9qXeEpfrAZbHfPoWcsTOd5oXIndp4Ts2IGO8+NiBHsPPdwjPWBEhaDmQ2WxO7uocdWVOcN6lxq502iYsGu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iLYuE7kqk7LLJHfZ/pSpYLrfBotgDU9tkHzuAqssiSMLfFnJ3CtaPUZfhPuI62QVXTZ2a/h3yJ2Mvdiysdu4Yey7D6inPGxm66X4bf3wJZe
@Pzixel
Pzixel / Converter.cs
Last active January 12, 2021 09:58
Allows flattening JSON struct when (de)serializing
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
namespace ConsoleApp15
As a gaming website we want to implement a tournament service with a feature called "Back a friend".
Each player holds certain amount of bonus points. Website funds its players with bonus points based on all kind of activity. Bonus points can traded to goods and represent value like real money.
One of the social products class is a social tournament. This is a competition between players in a multi-player game like poker, bingo, etc)
Entering a tournament requires a player to deposit certain amount of entry fee in bonus points. If a player has not enough point he can ask other players to back him and get a part the prize in case of a win.
In case of multiple backers, they submit equal part of the deposit and share the winning money in the same ration.
From a technical side, the following API service with 5 endpoints should be implemented
#1 Take and fund player account
GET /take?playerId=P1&points=300 takes 300 points from player P1 account
GET /fund?playerId=P2&points=300 funds (add to balance) player P2 wi
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, UndecidableInstances, LambdaCase #-}
import Control.Monad.State
import Control.Monad.Writer
import Data.Foldable
instance Monad m => Functor (CoroutineT m) where
fmap f m = CoroutineT $ do
result <- runCoroutineT m
@Pzixel
Pzixel / IO.rs
Last active June 21, 2020 21:20
pub struct IO<T>(Box<dyn FnOnce() -> T>);
impl<T: 'static> IO<T> {
pub unsafe fn perform_io(self) -> T {
self.0()
}
pub fn new(f: impl FnOnce() -> T + 'static) -> Self {
Self(Box::new(f))
}
module Main
%default total
data Vect : Nat -> Type -> Type where
Nil : Vect Z a
(::) : a -> Vect k a -> Vect (S k) a
data Elem : a -> Vect k a -> Type where
Here : Elem x (x :: xs)
module Main
import Debug.Trace
import Data.Vect;
-- infix 4 :+:
-- data Vect : Nat -> Type -> Type where
-- Nil : Vect Z a
-- (:+:) : a -> Vect k a -> Vect (S k) a