Skip to content

Instantly share code, notes, and snippets.

View kvasdopil's full-sized avatar

Alexey Guskov kvasdopil

  • Ombori
  • Stockholm, Sweden
View GitHub Profile
@kvasdopil
kvasdopil / sdgfdsg.py
Last active February 14, 2017 13:47 — forked from anonymous/sdgfdsg
import os, time, re
import paramiko
from zbxsend import Metric, send_to_zabbix
#Параметры для подключения по ssh
username='root' # ssh: login
ssh_key='/root/.ssh/id_dsa.pub' # ssh: password
port=22 # ssh: port
back_servs = [ea1-wal-backups, ea1-wal-backup2, ea1-wal-backup3, ea1-wal-backup4]
export const findFile = (node, fn, pathToFile = '') => {
const filePath = path.join(pathToFile, node.name);
if (node.type === 'directory') {
return node.children
.map(element => findFile(element, fn, filePath))
.reduce((res, found) => [...res, ...found], []);
}
if (fn(node)) {
return [filePath];
}
@kvasdopil
kvasdopil / justDuIt.js
Last active April 16, 2018 13:43 — forked from tuor4eg/justDuIt
export const countSize = (node) => {
reduce((size, element) => {
if (element.type === 'file') {
return (size + element.meta.size);
}
return size;
}, node, 0);
export default (tree) => {
const duIt = tree
export default (backendUrl, currentUrl) => {
return new Promise((resolve, reject) => {
get(backendUrl)
.then(response => {
if (response.status !== 200) {
reject(new Error(response.status));
return;
}
const parseJs = JSON.parse(response.data);
const checkLoad = Promise.all(parseJs.map(element => {
@kvasdopil
kvasdopil / server.js
Last active July 16, 2018 14:40 — forked from tuor4eg/server.js
const readFileAsync = file => new Promise((resolve, reject) => {
fs.readFile(file, (err, data) => err ? reject(err) : resolve(data));
});
const records = async (req, res) => {
await readFileAsync('phonebook.txt');
const count = readBook.toString().split('\n').length - 1;
const str = `Welcome to The Phonebook\nRecords count: ${count}`;
res.write(str);
};
export default class BtnGroup extends React.Component {
state = {
active: null
};
onClick = (id) => {
this.setState({ active: id });
}
render() {