Skip to content

Instantly share code, notes, and snippets.

View yarkovaleksei's full-sized avatar
🏠
Working from home

Yarkov Aleksey yarkovaleksei

🏠
Working from home
  • Russia, Rostov-on-Don
View GitHub Profile
#!/bin/sh
#######################################################
# UNIX TREE #
# Version: 2.3 #
# File: ~/apps/tree/tree.sh #
# By Dem Pilafian #
# #
# Displays Structure of Directory Hierarchy #
# ------------------------------------------------- #
# This tiny script uses "ls", "grep", and "sed" #
@yarkovaleksei
yarkovaleksei / script-template.sh
Created November 18, 2021 15:16 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@yarkovaleksei
yarkovaleksei / dom-to-json.js
Created April 5, 2019 07:57 — forked from sstur/dom-to-json.js
Stringify DOM nodes using JSON (and revive again)
function toJSON(node) {
node = node || this;
var obj = {
nodeType: node.nodeType
};
if (node.tagName) {
obj.tagName = node.tagName.toLowerCase();
} else
if (node.nodeName) {
obj.nodeName = node.nodeName;
@yarkovaleksei
yarkovaleksei / RadialProgressBar.spec.ts
Created September 28, 2018 09:52
RadialProgressBar component
import { mount } from '@vue/test-utils'
import RadialProgressBar from './RadialProgressBar.vue'
let wrapper: any
describe('ui/primitives/RadialProgressBar', () => {
beforeEach(() => {
wrapper = mount(RadialProgressBar, {
propsData: {
size: 18,
@yarkovaleksei
yarkovaleksei / Highlight.spec.ts
Created September 28, 2018 09:49
Highlight component
import { mount } from '@vue/test-utils'
import Highlight from './Highlight.vue'
let wrapper: any
describe('ui/Highlight', () => {
beforeEach(() => {
wrapper = mount(Highlight, {
propsData: {
search: '',
@yarkovaleksei
yarkovaleksei / checkBraces.js
Created September 19, 2018 11:02
jstest tasks
/**
* See demo (https://jsfiddle.net/yarkov_aleksei/e4Lwoq1g/)
*/
const braces = [['{', '}'], ['[', ']'], ['(', ')'], ['<', '>']]
const strBraces = braces.map(b => b.join('')).join('')
function isOpen(char) {
for (let i = 0; i < braces.length; i++) {
if (braces[i][0] === char) {
@yarkovaleksei
yarkovaleksei / 1. Example.scss
Created May 18, 2018 09:55 — forked from Integralist/1. Example.scss
Sass Mixin for CSS3 Animations
@include keyframe(fadeout) {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
import socketIo = require('socket.io-client')
const client = socketIo.connect('http://localhost:8080')
setInterval(() => {
client.emit('custom_stream', Buffer.from('aaaa'))
}, 1000)
@yarkovaleksei
yarkovaleksei / class_decorator.ts
Created April 26, 2018 14:21 — forked from remojansen/class_decorator.ts
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@yarkovaleksei
yarkovaleksei / jwtParse.js
Created April 13, 2018 16:15
Decode jwt token
function parseJwt (token) {
const base64Url = token.split('.')[1]
const base64 = base64Url.replace('-', '+').replace('_', '/')
return JSON.parse(window.atob(base64))
}
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVhNGQxMWExNjQ0ZWZmMDAwMTI0ZjA1ZiIsImlhdCI6MTUyMzYzNTgyOSwiZXhwIjoxNTIzNzIyMjI5fQ.Vhfcry3B9fqP1MmZ9Sz_VZK8FfVOwQ72MoGyvR0idNU'
console.clear()
console.log(parseJwt(token))