Skip to content

Instantly share code, notes, and snippets.

View dobeerman's full-sized avatar
🤔
I may be slow to respond.

Alexander Smirnoff dobeerman

🤔
I may be slow to respond.
View GitHub Profile
@dobeerman
dobeerman / checkfile.js
Last active December 26, 2017 10:47
Check files Promise
var year =
new Date()
.getFullYear()
.toString()
.substr(-2) *
1 +
1;
var compile = _.template(
"http://www.cbr.ru/statistics/b_sector/loans_nonfin_<%= year %>.xlsx"
@dobeerman
dobeerman / snippets.cson
Created January 20, 2018 04:14
Atom React snippets
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
@dobeerman
dobeerman / actions.js
Last active January 30, 2018 13:21
Vue.js auth actions
/*eslint no-undef: 0*/
import {USER_LOGGED_IN, USER_LOGGED_OUT} from '../types'
import api from '../api'
export default {
userLoggedIn: ({commit}, user) =>
commit({
type: USER_LOGGED_IN,
user
}),
var https = require('https')
var options = {
host: 'google.com',
method: 'get',
path: '/',
// To avoid an error, because the cert can be unauthorized
rejectUnauthorized: false
}
@dobeerman
dobeerman / axios-instance-config.js
Created February 11, 2018 01:24 — forked from ccnokes/axios-instance-config.js
Good default configuration for axios in node.js
const axios = require('axios');
const http = require('http');
const https = require('https');
module.exports = axios.create({
//60 sec timeout
timeout: 60000,
//keepAlive pools and reuses TCP connections, so it's faster
httpAgent: new http.Agent({ keepAlive: true }),
// if you are on node like me and you are using v >= 6,
// there was a change and you should use Buffer.from or similar.
function getBase64(url) {
return axios
.get(url, {
responseType: 'arraybuffer'
})
.then(response => Buffer.from(response.data, 'binary').toString('base64'))
}
axios.interceptors.request.use((config) => {
config.foo = 123;
});
const instance = axios.create();
instance.interceptors.request.use((config) => {
config.foo = 456;
});
axios.get('/foo'); // config.foo === 123 -> true
@dobeerman
dobeerman / axiosEncodings.js
Created February 15, 2018 01:48
Encoding RSS response "on the fly"
const axios = require('axios')
const xml2js = require('xml2js')
const iconv = require('iconv-lite')
const parser = new xml2js.Parser({ explicitArray: false })
var url = '[YOUR_WINDOWS-1251-RSS]'
axios.interceptors.response.use(async (response) => {
var contentType = response.headers['content-type']
@dobeerman
dobeerman / index.js
Created March 6, 2018 10:02
Import a couple of components as global at once. Make main.js more beauty ;)
// @file: src/components/global/index.js
// Global components
import FirstComponent from '.FirstComponent'
import SecondComponent from '.SecondComponent'
import ThirdComponent from '.ThirdComponent'
import FourthComponent from '.FourthComponent'
import FifthComponent from '.FifthComponent'
export default {
'first-component': FirstComponent,
<template>
<draggable v-model="filters" :options="{handle:'.handle-item', animation: 500}">
<transition-group>
<template v-for="(filter, idx) in filters">
<v-layout row wrap :key="idx">
<v-flex pt-4 xs1 text-xs-center v-if="filters.length > 1">
<v-icon class="handle-item">reorder</v-icon>
</v-flex>
<v-flex xs6>
<v-text-field v-model="filter.expression"