Skip to content

Instantly share code, notes, and snippets.

View example.js
let counter = 1;
function doInDelay(counterRecieved) {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (counter > counterRecieved) {
return;
}
resolve("Hi") //do filter
}, 2000)
View paste
https://gist.github.com/e16bb804d2bc9a95a4a9c0e2efe15024
View paste
{
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",
View api-docs-service.js
const express = require('express');
const path = require('path');
const swaggerCombine = require('swagger-combine');
const config = {
swagger: '2.0',
info: {
title: 'v4 API',
version: {
View menu_items.js
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
printing two dimensional board
View print_board.js
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 Jun 24, 2019
FEM: Exercise 1 starter
View .block
license: mit
@avivshafir
avivshafir / Valid Palindrome II.js
Created Oct 20, 2018
Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome.
View Valid Palindrome II.js
//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 Apr 23, 2018
fp in scala part 1
View fp_scala_p1.scala
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 Mar 5, 2018
Injecting the redux form reducer on the component load
View GenerateTags.tsx
public componentDidMount() {
const reduxFormReducer = require("redux-form").reducer;
injectAsyncReducer(store, "form", reduxFormReducer);
}