Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Yarkov Aleksey yarkovaleksei

🏠
Working from home
  • Russia, Rostov-on-Don
View GitHub Profile
@yarkovaleksei
yarkovaleksei / is-private-mode.js
Created Aug 7, 2019 — forked from jherax/is-private-mode.js
Detect if the browser is running in Private mode (Promise based)
View is-private-mode.js
// uncomment if you are transpiling with Babel + Webpack
// const { window, document } = global;
/**
* Lightweight script to detect whether the browser is running in Private mode.
* @returns {Promise}
*
* Live demo:
* @see http://live.datatables.net/piduzelo/1
*
@yarkovaleksei
yarkovaleksei / dom-to-json.js
Created Apr 5, 2019 — forked from sstur/dom-to-json.js
Stringify DOM nodes using JSON (and revive again)
View dom-to-json.js
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;
View vuelidate.d.ts
declare module 'vuelidate' {
// we need to augment the actual Vue types
import vue from 'vue'
// must bolt on the validations property to the input of ComponentOptions
// and also onto the "output" of @Component in the form of VueClass<Vue>
module 'vue/types/options' {
// tslint:disable-next-line
interface ComponentOptions<V extends vue> {
validations?: { [x: string]: any }
View RadialProgressBar.spec.ts
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,
View Highlight.spec.ts
import { mount } from '@vue/test-utils'
import Highlight from './Highlight.vue'
let wrapper: any
describe('ui/Highlight', () => {
beforeEach(() => {
wrapper = mount(Highlight, {
propsData: {
search: '',
View checkBraces.js
/**
* 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 — forked from Integralist/1. Example.scss
Sass Mixin for CSS3 Animations
View 1. Example.scss
@include keyframe(fadeout) {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
View client.ts
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 Apr 26, 2018 — forked from remojansen/class_decorator.ts
TypeScript Decorators Examples
View class_decorator.ts
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);
}
View jwtParse.js
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))
You can’t perform that action at this time.