Skip to content

Instantly share code, notes, and snippets.

View IhostVlad's full-sized avatar
💻
Senior full-stack developer

Vladislav V IhostVlad

💻
Senior full-stack developer
View GitHub Profile
@IhostVlad
IhostVlad / Eval with CSP
Created April 19, 2019 09:26
Eval with CSP
window.metaEval = async (code) => {
const evalId = "META_EVAL_"+ Date.now() + "_" + Math.floor(Math.random() * 1000000000)
document.body.innerHTML += "<iframe id=\""+ evalId +"\" src=\"about:blank\"></iframe>"
const ifr = document.getElementById(evalId)
let makeResolve = null
const promise = new Promise((resolve) => (makeResolve = resolve))
let result = null
const listener = (msg) => { result = msg.data; makeResolve(); }
window.addEventListener("message", listener)
function conditionalRequireModuleByPath(modulePath, condition) {
try {
var packageJson = require(path.join(modulePath, './package.json'))
if (condition(packageJson)) {
return require(path.join(
modulePath,
'./',
packageJson.main || 'index.js'
))
}
@IhostVlad
IhostVlad / SafeInvokeFs
Created April 3, 2018 15:31
SafeInvokeFs
const safeInvokeFs = (funcName, ...args) =>
new Function(
'context',
`try {
return require('fs')[context.funcName].apply(null, context.args)
} catch(err) {}`
)({ funcName, args })
(function() {
!(function(global) {
"use strict";
var Op = Object.prototype;
var hasOwn = Op.hasOwnProperty;
var undefined;
var $Symbol = typeof Symbol === "function" ? Symbol : {};
var iteratorSymbol = $Symbol.iterator || "@@iterator";
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
@IhostVlad
IhostVlad / babel-object-source.js
Created October 24, 2017 10:10
Babel plugin adds meta-information to all objects in source code, including file name, line number and original text, where object had been declated
module.exports = function ({ types: t }) {
const WRAP_NAME = '__WRAP_OBJECT_CREATION_WITH_SOURCE_MAP__';
const SOURCE_NAME = '__SOURCE_DELCARATION__';
return {
visitor: {
'ObjectExpression|ArrayExpression|NewExpression': function (path, state) {
const wrappedParent = path.findParent(
parent =>
parent.node &&
parent.node.callee &&

resolve-bus-memory npm version

This package is a driver for resolve-es to emit events using memory.

Usage

import createDriver from 'resolve-bus-memory';

const driver = createDriver();
@IhostVlad
IhostVlad / DockerTestcafe.hint
Last active April 14, 2019 09:04
Docker for TestCafe + Chrome + X11 + VNC
##### ./testcafe_ubuntu.dockerfile #####
# Pull base image.
FROM ubuntu:16.04
ENV LC_ALL C
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true
# Install.
RUN \