Skip to content

Instantly share code, notes, and snippets.

@pphetra
pphetra / app.service.spect.ts
Last active March 8, 2023 05:05
test_optimistic_lock
/** @format */
describe("AppService", () => {
const client = new PrismaClient({
// log: ['query', 'info', 'warn'],
});
afterAll(async () => {
await client.$disconnect();
});
@pphetra
pphetra / app.service.spec.ts
Last active March 3, 2023 05:37
aggregate
/** @format */
import { PrismaClient } from "@prisma/client";
import { Batch, Product } from "./app.model";
import { IProductRepository } from "./app.repository";
import { AppService } from "./app.service";
import { AbstractUnitOfWork, PrismaUnitOfWork } from "./unitOfWork";
class FakeProductRepository implements IProductRepository {
constructor(private batches: Batch[]) {}
from pyspark.sql.functions import max
covid060320.select(max("Deaths")).take(1)
covid060320 = spark\
.read\
.option("inferSchema", "true")\
.option("header", "true")\
.csv("03-06-2020.csv")
covid060320.take(10)
covid060320.sort("Deaths").explain()
import { Injectable } from "@nestjs/common";
import { DictionaryService } from "dictionary.service";
import { State, HangmanGame } from "hangman";
import { Observable } from "rxjs";
import { first } from "rxjs/operators";
const games = new Map<string, HangmanGame>()
var currentGameId = 1
import { Controller, Post, Get, Param, Put, Res } from "@nestjs/common";
import { HangmanService } from "hangman.service";
@Controller('hangman')
export class HangmanController {
constructor(private readonly hangmanService: HangmanService) {}
@Post()
newGame() {
return this.hangmanService.createNewGame()
import { Subject, Observable, interval, merge } from "rxjs";
import { map, scan, share } from 'rxjs/operators';
export const MAX_LIFE = 7
export const MAX_TIME = 5
export type State = {
gameId: string,
status: string,
knownSecretWord: Array<string>,
import { Controller, Post, Get, Param, Put, Res } from "@nestjs/common";
import { HangmanService } from "hangman.service";
@Controller('hangman')
export class HangmanController {
constructor(private readonly hangmanService: HangmanService) {}
@Post()
newGame() {
return this.hangmanService.createNewGame()
package com.example
import akka.actor.ActorSystem
import akka.stream._
import akka.stream.scaladsl.Source
import akka.{Done, NotUsed}
import scala.collection.immutable.ListSet
import scala.concurrent.{ExecutionContextExecutor, Future}
@pphetra
pphetra / hangman.ts
Last active September 28, 2018 23:32
import {from, Observable} from 'rxjs';
import {reduce} from "rxjs/operators";
import reduceReducers from "reduce-reducers";
const MAX_LIFE = 7;
const zip = (arr1: Array<string>, arr2: Array<string>) => arr1.map((e, i) => [e, arr2[i]])
type State = {
status: string,