Skip to content

Instantly share code, notes, and snippets.

View sanchezzzhak's full-sized avatar
🦙
lama no prob llama

Tutik Alexsandr sanchezzzhak

🦙
lama no prob llama
View GitHub Profile
@sanchezzzhak
sanchezzzhak / Epic One
Created March 22, 2023 10:13
models list for brands
E1 (TINY I)
E3 (TINY III)
E4 (TINY)
K400 (PEBBLE)
K405 (PEBBLE II)
K406 (PEBBLE MAX)
K500 (OMEGA LITE)
K501 (LEO)
K502 (OMEGA)
K503 (LEO MAX)
@sanchezzzhak
sanchezzzhak / CalculateStars.php
Created January 13, 2022 08:45
counts the number of stars based on like, unlike for PHP
<?php
// ...
trait CalculateStars {
/**
* подсчитывает количество звезд на основе like, unlike
*
* @param int $stars - количество звезд
* @param int $round - округление по умолчанию до целого
* @return float|int
*/
https://play.google.com/store/apps/details?id=com.startpage.mobile
Mozilla/5.0 (Android 11;) AppleWebKit/1.1 Version/4.0 Mobile Safari/1.1
@sanchezzzhak
sanchezzzhak / TuiEditor.php
Created October 31, 2019 09:53
Yii2 TuiEditor Widget
<?php namespace app\widgets;
use app\assets\TuiEditorAsset;
use yii\web\JsExpression;
use yii\widgets\InputWidget;
use yii\helpers\Html;
use yii\helpers\Json;
/**
* Class TuiEditor
@sanchezzzhak
sanchezzzhak / detect-device.service.js
Last active June 11, 2019 17:21
Molecularjs service device detect (es6 for nodejs 12+ private property)
const Service = require("moleculer").Service;
const DetectDetector = require('node-device-detector');
const MemCache = require("../mixins/memcache");
const crypto = require('crypto');
const DEVICE_TYPE = require('node-device-detector/parser/const/device-type');
/**
* @typedef {Object} DetectCtxParams
* @property {String} userAgent
const Memcached = require('memcached');
module.exports = ({keyComponent: componentName = 'memcache', config: config} = {}) => ({
settings: {
[componentName]: config,
},
created() {
this[componentName] = new Memcached(this.settings[componentName]);
// this[componentName].TIME_MAX = 2592000;
// this[componentName].TIME_DAY = 86400;
@sanchezzzhak
sanchezzzhak / MiscHelper.php
Created April 15, 2019 08:46
Compare 2 arrays values $old and $new and return array [ new values, unchanged values, deleted values]
<?php
/**
* Class MiscHelper
* @package app\helpers
*/
class MiscHelper
{
/**
* ```php
@sanchezzzhak
sanchezzzhak / a_docs.md
Last active April 3, 2019 12:36
nsfwjs micro service from molecular (nodejs)

Download archrive https://github.com/GantMan/nsfw_model and extract dir project/data/nsfw

  // get post data to buffer result
	getBinaryDataFromRequest(req) {
	  return new Promise((resolve) => {
		const chunks = [];
		req.on('data', (chunk) => {
		  chunks.push(chunk);
		});
@sanchezzzhak
sanchezzzhak / nodejs mongo seve loop
Last active January 15, 2019 08:19
JS nodejs mongo seve loop
"use strict";
const EventEmitter = require('events').EventEmitter
const mongodb = require('mongodb');
const MONGODB_EVENTS = {
RECONNECT: 'reconnect',
RECONNECT_FAILED: 'reconnectFailed',
LEFT: 'left',
JOINED: 'joined',
@sanchezzzhak
sanchezzzhak / Theme.php
Created February 27, 2018 14:22
Yii2 theme component snipet
<?php
namespace app\components;
use Yii;
use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper;
use yii\helpers\FileHelper;
class Theme extends \yii\base\Theme
{