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 / ISO3166_RU.json
Created July 22, 2015 11:35
Список кодов Стран по ISO 3166 в 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"
@sanchezzzhak
sanchezzzhak / test_mongo_short_id.php
Created November 23, 2016 11:55
mongo short id
<?php
class Base62 {
const CHARS_SYMBOLS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-';
/**
* @param $id
* @return string
*/
public static function encode($id){
@sanchezzzhak
sanchezzzhak / StatGrid.php
Created August 9, 2017 16:09
GridView closure options test example
<?php
interface IStat {
const GROUP_HOUR = 'hour';
}
class StatGrid extends Object
{
/** @var Stat */
public $model;
/** @var SqlDataProvider */
@sanchezzzhak
sanchezzzhak / clickhouse-get-tables-size.sql
Created January 18, 2018 13:43
clickhouse get tables size
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 / 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
{
@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 / 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 / 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
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 / 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