Skip to content

Instantly share code, notes, and snippets.

View abler98's full-sized avatar
🇺🇦
Все буде Україна!

Serhii Semenko abler98

🇺🇦
Все буде Україна!
  • Kharkiv, Ukraine
View GitHub Profile
@abler98
abler98 / php-join_array.php
Created April 2, 2016 16:50
PHP join_array function
<?php
function join_array(array $array, $divider = '.') {
$iterator = new RecursiveArrayIterator($array);
$new_array = [];
$recursive = function (RecursiveArrayIterator $iterator, $parent = null) use (&$recursive, &$new_array, $divider) {
while ($iterator->valid()) {
$path = !is_null($parent) ? $parent . $divider . $iterator->key() : $iterator->key();
if ($iterator->hasChildren()) {
@abler98
abler98 / album-store.vue
Last active October 11, 2016 09:20
Vue Component
<template>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Загрузить фотографию
</div>
<div class="panel-body" v-notifications>
<form :action="source" @submit.prevent="store" role="form">
<div v-if="photo" class="form-group">
/**
* Бот для csgo.life
*/
console.log('Запуск бота...');
// var io = io(config.host);
var io = SOCKET;
const TYPE_HELLO = "hello";
@abler98
abler98 / queued-upload-requests.js
Created November 22, 2016 19:47
Uploading files to server with queues
/*
* Загружает файл на сервер
*/
var requestQueue = [],
sendingRequest = false;
window.attachRequestToQueue = (queue) => {
requestQueue.push(queue);
doRequestQueue();
<?php
namespace App\Models;
use Illuminate\Http\Exception\HttpResponseException;
use Illuminate\Http\UploadedFile;
use Intervention\Image\Constraint;
use Intervention\Image\Exception\NotWritableException;
class Photo extends \Eloquent
<?php
function hex2rgb($color = '#fff')
{
$color = ltrim($color, '#');
$length = strlen($color);
if (preg_match('/[^0-9a-f]/i', $color) or $length <> 3 && $length <> 6) {
throw new Exception('Invalid color format');
}
@abler98
abler98 / AbstractPresenter.php
Created January 13, 2017 10:24 — forked from Ellrion/AbstractPresenter.php
Презентеры в Laravel.
<?php
namespace App\Presenters;
abstract class AbstractPresenter
{
/**
* The resource that is the object that was decorated.
*
* @var mixed
@abler98
abler98 / vk-audio-downloader.js
Last active April 30, 2023 17:59
Скрипт для скачивания музыки VK
/*
Инструкция по использованию:
- заходим в раздел с аудиозаписями
- листаем в самый низ (чтобы прогрузились все аудиозаписи)
- открываем консоль браузера (F12 -> Консоль)
- вставляем код и нажимаем ENTER
- скачивание началось...
- браузер может потребовать разрешение на сохранение файлов, необходимо подтвердить действие
@abler98
abler98 / movie-titles.rb
Created August 3, 2017 09:29 — forked from karmi/movie-titles.rb
Multiple analyzers and query fields in Elasticsearch for auto-completion
require 'tire'
# Tire.configure { logger STDERR, level: 'debug' }
Tire.index('movie-titles') do
delete
create \
settings: {
index: {
analysis: {
@abler98
abler98 / ngram-search.sh
Created August 4, 2017 18:15 — forked from avar/ngram-search.sh
ElasticSearch fuzzy ngram powered search
export http_proxy=
export https_proxy=
curl -XDELETE 'http://localhost:9200/test/'
echo "Creating the mapping"
curl -XPUT 'http://localhost:9200/test/?pretty=1' -d '
{
"mappings" : {
"member" : {