Skip to content

Instantly share code, notes, and snippets.

View alexey-kar's full-sized avatar

Alexey Karchevskii alexey-kar

View GitHub Profile
@alexey-kar
alexey-kar / Не работает Vue Devtools
Created July 15, 2019 09:25
Не работает Vue Devtools
https://github.com/vuejs/vue-devtools/issues/620
This may be brittle but in production if you are not getting a connection of vue 2.x.13 you can do this. We wanted this in our QA environments when needed.
// Before you create app
Vue.config.devtools = true;
// After you create app
window.__VUE_DEVTOOLS_GLOBAL_HOOK__.Vue = app.constructor;
@alexey-kar
alexey-kar / num2str.php
Created July 3, 2019 14:49 — forked from bupy7/num2str.php
Сумма прописью
<?php
/**
* Возвращает сумму прописью
* @author runcore
* @uses morph(...)
*/
function num2str($num) {
$nul='ноль';
$ten=array(
array('','один','два','три','четыре','пять','шесть','семь', 'восемь','девять'),
@alexey-kar
alexey-kar / dowload_file_by_link,js
Last active July 2, 2019 21:00
Скачать файл js по ссылке
@alexey-kar
alexey-kar / download-file.js
Last active April 19, 2023 16:27
Download files with AJAX (axios) / Download files with AJAX (Laravel)
// use responseType: 'blob'
axios({
url: 'http://localhost/download_pdf',
method: 'GET',
responseType: 'blob', // <--
}).then(response => {
const blob_file = response.data;
const file_url = URL.createObjectURL(blob_file);
window.open(file_url); // open file in new tab
});
// при изменении токена в одной вкладке, меняем во всех остальных
// на пример когда в одной вкладке пользователь разлогинился, разлогинится должно и в остальных вкладках
$(window).on('storage', function (e) {
if (e.originalEvent.key == 'token') {
let token = e.originalEvent.newValue;
window.axios.defaults.headers.common['Authorization'] = `Bearer ${token}`;
store.commit('LOGIN', {token});
}
});
@alexey-kar
alexey-kar / gist:7e9414d66a39320512b33bd1be363077
Created December 3, 2018 05:12
vue axios set header before all queries
window.axios.interceptors.request.use(
config => {
/*
const token = localStorage.getItem('token');
if (token) {
console.log(token);
config.headers.Authorization = `Bearer ${token}`;
} else {
@alexey-kar
alexey-kar / index.js
Created November 23, 2018 06:44
Jquery Программное сочетание клавиш / Jquery trigger shortcut
// variant 1. Press Ctrl+W
var e = jQuery.Event("keypress");
e.which = 'w'.charCodeAt(); // # Some key code value
e.ctrlKey = true;
$(document).trigger(e);
// variant 2. Press Ctrl+W
$.event.trigger({ type : 'keypress', which : 'w'.charCodeAt(), ctrlKey: true });
SELECT IBLOCK_ELEMENT_ID, COUNT(VALUE), VALUE FROM `b_iblock_element_property` WHERE `IBLOCK_PROPERTY_ID` = 21 AND `IBLOCK_ELEMENT_ID` = 63426 GROUP BY VALUE
SELECT IBLOCK_ELEMENT_ID, COUNT(VALUE), VALUE FROM `b_iblock_element_property` WHERE `IBLOCK_PROPERTY_ID` = 1412 AND `IBLOCK_ELEMENT_ID` = 63426 GROUP BY VALUE
@alexey-kar
alexey-kar / download.php
Created January 29, 2018 21:01
Файл для скачивания файла, будет скачивать файл оставаясь на текущей странице. Вызывать так download.php?id=123
<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
function download_translit($filename) {
static $tbl = array(
'а'=>'a', 'б'=>'b', 'в'=>'v', 'г'=>'g', 'д'=>'d', 'е'=>'e', 'ж'=>'g', 'з'=>'z',
'и'=>'i', 'й'=>'y', 'к'=>'k', 'л'=>'l', 'м'=>'m', 'н'=>'n', 'о'=>'o', 'п'=>'p',
'р'=>'r', 'с'=>'s', 'т'=>'t', 'у'=>'u', 'ф'=>'f', 'ы'=>'y', 'э'=>'e', 'А'=>'A',
'Б'=>'B', 'В'=>'V', 'Г'=>'G', 'Д'=>'D', 'Е'=>'E', 'Ж'=>'G', 'З'=>'Z', 'И'=>'I',
AmCharts.themes.rk = {
AmChart: {
color: "#000000"
},
AmCoordinateChart:
{
colors: ["#4f81bd", "#ff0000", "#77933c", "#c9e6f2", "#c9f0e1",
"#e8d685", "#e0ad63", "#d48652", "#d27362", "#495fba", "#7a629b",