Skip to content

Instantly share code, notes, and snippets.

View Maksclub's full-sized avatar

Maksim Maksclub

  • Tbilisi, Georgia
View GitHub Profile
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';
}
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;
@Maksclub
Maksclub / app.component.ts
Created September 21, 2022 21:59 — forked from Orabig/app.component.ts
Centrifugo Client Service for Angular 2 #Centrifugo #Angular2 #service
// 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',
################################################################
# MIGRATIONS
################################################################
LOCAL_BIN := $(CURDIR)/bin
GOOSE_VERSION :=v2.7.0
GOOSE_BIN := $(LOCAL_BIN)/goose
# Директория с миграцими
version: "3"
services:
mongodb:
image: mongo:latest
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: rootpassword
ports:
- 27017:27017
volumes:
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)
version: "3.5"
services:
nginx:
image: nginx
volumes:
- ./:/app:ro
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
restart: "always"
ports:
<?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;
@Maksclub
Maksclub / ConcreteVisitor.php
Last active June 13, 2019 20:53
Конкретный посетитель
<?php
class SecretVisitor implements Visitor
{
public function visitEmailSender(EmailSender $emailSender)
{
# Отправляем сообщение о том, что есть некое секретное сообщение в кабинете
}
public function visitSmsSender(SmsSender $smsSender)
@Maksclub
Maksclub / visitorExample.php
Last active June 13, 2019 20:32
Объяснение реализации Посетителя
<?php
class EmailSender implements SenderInterface
{
# prev behavior
public function accept(Visitor $visitor)
{
$visitor->visitSenderEmail($this);
}