Skip to content

Instantly share code, notes, and snippets.

View Maksclub's full-sized avatar

Maksim Maksclub

  • Tbilisi, Georgia
View GitHub Profile
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;
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';
}
@Maksclub
Maksclub / delete.php
Created December 15, 2017 19:04
Удаление всех товаров в Симпле
if($_REQUEST['clear_products']){
$backend->db->query('TRUNCATE s_variants');
$backend->db->query('TRUNCATE s_products');
$backend->db->query('TRUNCATE s_images');
$backend->db->query('TRUNCATE s_related_products');
$backend->db->query('TRUNCATE s_products_categories');
$backend->db->query('TRUNCATE s_options');
}
@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',
@Maksclub
Maksclub / search.js
Created December 15, 2017 08:18
search_ya
/*********************************
Поиск на Яндексе
*********************************/
$("#search_ya").autocomplete( {
source: function(request, response) {
$.ajax( {
url: "https://catalogapi.site.yandex.net/v1.0",
dataType: "json",
data: {
@Maksclub
Maksclub / Products.php
Created November 24, 2018 09:14
Exclude ids
...
// В начале метода get_products(), где инициализируются переменные
$exclude_id_filter = '';
...
// В середине файла, где идут схожие првоерки и наполняются пременные
if(!empty($filter['exclude_id'])) {
$exclude_id_filter = $this->db->placehold('AND p.id NOT IN (?@)', (array)$filter['exclude_id']);
}
################################################################
# 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: