Skip to content

Instantly share code, notes, and snippets.

let counter = 1;
function doInDelay(counterRecieved) {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (counter > counterRecieved) {
return;
}
resolve("Hi") //do filter
}, 2000)
https://gist.github.com/e16bb804d2bc9a95a4a9c0e2efe15024
{
swagger: "2.0",
info: {
title: "ClimaCell v4 API",
version: "1.0.0"
},
paths: {
/locations/{locationId}: {
get: {
description: "Returns an location based on a single ID",
@avivshafir
avivshafir / api-docs-service.js
Created June 22, 2020 18:02
API v4 Docs Service
const express = require('express');
const path = require('path');
const swaggerCombine = require('swagger-combine');
const config = {
swagger: '2.0',
info: {
title: 'v4 API',
version: {
class MenuItem {
constructor(menuItems = []) {
this.menuItems = menuItems;
this.isVisible = false;
}
onClick = () => {
// if (this.menuItems.length !== 0) { //menu has no children -> run action
// //run action function
// } else {
@avivshafir
avivshafir / print_board.js
Created May 26, 2020 22:46
printing two dimensional board
let ROWS = 6;
let COLS = 6;
class Board {
constructor(props) {
this.cells = [];
for (let i = 0; i < ROWS; i++) {
for (let j = 0; j < COLS; j++) {
if (!this.cells[i]) {
this.cells[i] = [];
@avivshafir
avivshafir / .block
Created June 24, 2019 12:19
FEM: Exercise 1 starter
license: mit
@avivshafir
avivshafir / Valid Palindrome II.js
Created October 20, 2018 19:33
Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome.
//Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome.
//https://leetcode.com/explore/interview/card/facebook/5/round-1-phone-interview/289/
//Solution 1 - Not efficient o(n^2)
//---------------------------------------------------
var validPalindrome = function(s) {
for (let i = 0; i < s.length; i++) {
let w = s.substr(0, i) + s.substr(i + 1);
if (isPal(w)) {
return true;
@avivshafir
avivshafir / fp_scala_p1.scala
Last active April 23, 2018 07:01
fp in scala part 1
def fib(n: Int): Int = {
@annotation.tailrec
def loop(n: Int, prev: Int, cur: Int): Int =
if (n == 0) prev
else loop(n - 1, cur, prev + cur)
loop(n, 0, 1)
}
fib(6)
@avivshafir
avivshafir / GenerateTags.tsx
Last active March 5, 2018 19:20
Injecting the redux form reducer on the component load
public componentDidMount() {
const reduxFormReducer = require("redux-form").reducer;
injectAsyncReducer(store, "form", reduxFormReducer);
}