Skip to content

Instantly share code, notes, and snippets.

View akirpichnikov's full-sized avatar

Aleksey Kirpichnikov akirpichnikov

  • Odesa, Ukraine
View GitHub Profile
@akirpichnikov
akirpichnikov / difference.js
Last active July 25, 2019 11:24 — forked from Yimiprod/difference.js
Deep diff between two object, using lodash
/**
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
return _.transform(object, function(result, value, key) {
if (!_.isEqual(value, base[key])) {
@akirpichnikov
akirpichnikov / animation.ts
Created July 19, 2019 14:42
angular animation list add & delete
animations: [
trigger('items', [
transition(':enter', [
style({ opacity: 0 }),
animate('.1s ease-in',
style({ opacity: 1 }))
]),
transition(':leave', [
style({ opacity: 1}),
animate('.1s ease-out',
@akirpichnikov
akirpichnikov / consoleLog.ts
Last active July 11, 2019 12:33
Puppeteer console log
// from https://github.com/GoogleChrome/puppeteer/issues/3397#issuecomment-434970058
page.on('console', async msg => {
// serialize my args the way I want
const args = await Promise.all(msg.args().map(arg => arg.executionContext().evaluate(arg => {
// I'm in a page context now. If my arg is an error - get me its message.
if (arg instanceof Error) {
return arg.message;
}
// return arg right away. since we use `executionContext.evaluate`, it'll return JSON value of