Skip to content

Instantly share code, notes, and snippets.

👻
I have a black belt on GoogleSearch.

Tutik Alexsandr sanchezzzhak

👻
I have a black belt on GoogleSearch.
  • Russia, Voronezh
Block or report user

Report or block sanchezzzhak

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sanchezzzhak
sanchezzzhak / detect-device.service.js
Last active Jun 11, 2019
Molecularjs service device detect (es6 for nodejs 12+ private property)
View detect-device.service.js
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
View memcache.mixin.js
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 Apr 15, 2019
Compare 2 arrays values $old and $new and return array [ new values, unchanged values, deleted values]
View MiscHelper.php
<?php
/**
* Class MiscHelper
* @package app\helpers
*/
class MiscHelper
{
/**
* ```php
@sanchezzzhak
sanchezzzhak / a_docs.md
Last active Apr 3, 2019
nsfwjs micro service from molecular (nodejs)
View a_docs.md

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 Jan 15, 2019
JS nodejs mongo seve loop
View 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 Feb 27, 2018
Yii2 theme component snipet
View Theme.php
<?php
namespace app\components;
use Yii;
use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper;
use yii\helpers\FileHelper;
class Theme extends \yii\base\Theme
{
View clickhouse-get-tables-size.sql
SELECT table,
formatReadableSize(sum(bytes)) as size,
min(min_date) as min_date,
max(max_date) as max_date
FROM system.parts
WHERE active
GROUP BY table
@sanchezzzhak
sanchezzzhak / StatGrid.php
Created Aug 9, 2017
GridView closure options test example
View StatGrid.php
<?php
interface IStat {
const GROUP_HOUR = 'hour';
}
class StatGrid extends Object
{
/** @var Stat */
public $model;
/** @var SqlDataProvider */
View test_mongo_short_id.php
<?php
class Base62 {
const CHARS_SYMBOLS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-';
/**
* @param $id
* @return string
*/
public static function encode($id){
@sanchezzzhak
sanchezzzhak / ISO3166_RU.json
Created Jul 22, 2015
Список кодов Стран по ISO 3166 в json
View ISO3166_RU.json
[{
"flag_url" : "//upload.wikimedia.org/wikipedia/commons/thumb/b/b9/Flag_of_Australia.svg/22px-Flag_of_Australia.svg.png",
"name_ru" : "Австралия",
"iso_code2" : "AU",
"iso_code3" : "AUS"
}, {
"flag_url" : "//upload.wikimedia.org/wikipedia/commons/thumb/4/41/Flag_of_Austria.svg/22px-Flag_of_Austria.svg.png",
"name_ru" : "Австрия",
"iso_code2" : "AT",
"iso_code3" : "AUT"
You can’t perform that action at this time.