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
const SECOND = 1000; | |
const MINUTE = 60 * SECOND; | |
const HOUR = 60 * MINUTE; | |
export function formatPlayerTime(ms: number, options?: {withHour?: boolean}) { | |
if (ms <= 0) { | |
if (!!options?.withHour) { | |
return '00:00:00'; | |
} |
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
import {BehaviorSubject, Observable, Subject} from "rxjs"; | |
import {Injectable} from "@angular/core"; | |
import {filter} from "rxjs/operators"; | |
@Injectable() | |
export class PerformanceTimer { | |
private _currentTime$ = new BehaviorSubject<number>(0) | |
private timer: number | null = null; | |
private timeLimit = 0; | |
private unlimit = false; |
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
// Register your service as usual. I suggest adding it to [providers] in the module definition | |
// Then... | |
... | |
var user = ...; | |
var info = ...; // Optional | |
var timestamp = Date.now() / 1000 | 0; | |
var token = <Get the token from your ws>; | |
this.centrifugeService.connect({ | |
url: 'http://<centrifugoServer>:8000/connection', |
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
################################################################ | |
# MIGRATIONS | |
################################################################ | |
LOCAL_BIN := $(CURDIR)/bin | |
GOOSE_VERSION :=v2.7.0 | |
GOOSE_BIN := $(LOCAL_BIN)/goose | |
# Директория с миграцими |
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
version: "3" | |
services: | |
mongodb: | |
image: mongo:latest | |
environment: | |
MONGO_INITDB_ROOT_USERNAME: root | |
MONGO_INITDB_ROOT_PASSWORD: rootpassword | |
ports: | |
- 27017:27017 | |
volumes: |
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
type LoginCreds struct { | |
Password string `json:"password"` | |
Email string `json:"email"` | |
} | |
func (h *Handler) UserLogin(w http.ResponseWriter, req *http.Request) { | |
input := LoginCreds{} | |
dec := json.NewDecoder(req.Body) | |
if err := dec.Decode(&input); err != nil { | |
http.Error(w, "email and password not satisfied", http.StatusBadRequest) |
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
version: "3.5" | |
services: | |
nginx: | |
image: nginx | |
volumes: | |
- ./:/app:ro | |
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro | |
restart: "always" | |
ports: |
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
<?php | |
namespace Hunter\Application\InnerClass { | |
use Psr\Log\LoggerInterface; | |
use Symfony\Component\Console\Command\Command; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Output\OutputInterface; | |
use Symfony\Component\Finder\Finder; |
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
<?php | |
class SecretVisitor implements Visitor | |
{ | |
public function visitEmailSender(EmailSender $emailSender) | |
{ | |
# Отправляем сообщение о том, что есть некое секретное сообщение в кабинете | |
} | |
public function visitSmsSender(SmsSender $smsSender) |
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
<?php | |
class EmailSender implements SenderInterface | |
{ | |
# prev behavior | |
public function accept(Visitor $visitor) | |
{ | |
$visitor->visitSenderEmail($this); | |
} |
NewerOlder