Skip to content

Instantly share code, notes, and snippets.

View Bnaya's full-sized avatar
🐪

Bnaya Peretz Bnaya

🐪
View GitHub Profile
@Bnaya
Bnaya / track-errors.js
Created January 4, 2016 15:39
Track javascript errors to google analytics
(function () {
'use strict';
var duringErrorTrack = false;
var ua = 'UA-XXXXXX-X'
// don't break old browsers
if (!window.addEventListener) {
return;
}
@Bnaya
Bnaya / example.ts
Created March 11, 2018 01:04
You might not need promise/async helper library after all
// You probobly don't need a helper library for Promise/Async after all
const seedValues = [Promise.resolve(777), Promise.resolve(888)];
// reduce
// Promise based
seedValues
.reduce((accumulator, currentValue) =>
accumulator.then(v => currentValue.then(cv => v + cv))
)
@Bnaya
Bnaya / directory structure
Last active February 1, 2019 00:07
yarn-dedup-examples 1
.
├── node_modules
│ └── @types
│ ├── fs-extra
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── index.d.ts
│ │ └── package.json
│ └── node
│ ├── LICENSE
@Bnaya
Bnaya / before yarn deduplicate directory structure
Last active February 1, 2019 01:11
before yarn deduplicate
.
├── node_modules
│   └── @types
│   ├── fs-extra
│   │   ├── LICENSE
│   │   ├── README.md
│   │   ├── index.d.ts
│   │   ├── node_modules
│   │   │   └── @types
│   │   │   └── node
@Bnaya
Bnaya / compiled.js
Last active February 11, 2019 15:16
babel private fields playground
function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }
var id = 0;
function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; }
class Person {
constructor() {
Object.defineProperty(this, _increaseAge, {
value: _increaseAge2
@Bnaya
Bnaya / index.ts
Last active July 16, 2022 11:55
Typescript Types indirect re-export with isolatedModules: true
// Cannot re-export a type when the '--isolatedModules' flag is provided.ts(1205)
export { IMyInterface } from "./types"
// this works!
import { IMyInterface as IMyInterfaceForExport } from "./types"
export type IMyInterface = IMyInterfaceForExport;
// And Also:
export type IMyInterface2 = import("./types").IMyInterface;
@Bnaya
Bnaya / fetch-stream-json-parser.ts
Created April 9, 2019 08:24
fetch-stream-json-parser.ts basic code example
// https://github.com/dominictarr/JSONStream
// @ts-ignore
import JSONStream from "JSONStream";
import { Observable } from "rxjs";
class Bla {
public creativesOfChannelV4StreamEndpoint<T=any>(
channel: T,
brandId: string,
import React from "react";
import fs from "fs";
console.log(React, fs, __filename);
@Bnaya
Bnaya / myentities.ts
Last active September 28, 2020 03:24
typeorm-idonnowhattodo-1
import {
Entity,
JoinColumn,
ManyToOne,
Column,
PrimaryGeneratedColumn,
ManyToMany,
JoinTable,
OneToMany,
CreateDateColumn,
@Bnaya
Bnaya / ..serverless-project-chrome-aws-lambda_with_layer_for_node10.md
Last active October 15, 2019 15:58
- NOT NEEDED ANY MORE - lambda chrome node 10

serverless project with chrome-aws-lambda with layer for node10