Skip to content

Instantly share code, notes, and snippets.

@tanayv
tanayv / pattern.matching.js
Last active April 23, 2020 16:31
Pattern Matching Problem
/* Given a pattern and a string input - find if the string follows the same pattern and return 0 or 1. Examples: 1) Pattern : "abba", input: "redblueredblue" should return 1. 2) Pattern: "aaaa", input: "asdasdasdasd" should return 1. 3) Pattern: "aabb", input: "xyzabcxzyabc" should return 0. */
const isMatch = (pat, str) => {
if (pat.length === 0 || str.len === 0) return false;
for (let i = 0; i <= str.length; i++) {

Keybase proof

I hereby claim:

  • I am tanayv on github.
  • I am tanayv (https://keybase.io/tanayv) on keybase.
  • I have a public key whose fingerprint is 58A2 C7AE A23B A770 4DD8 D464 15D7 95CC 8D69 B17E

To claim this, I am signing this object:

@tanayv
tanayv / app.py
Created January 18, 2019 19:31
Clickbait Repel Flask App
from flask import Flask
import tensorflow as tf
import numpy as np
import os
import time
import datetime
import data_helpers
from text_cnn import TextCNN
from tensorflow.contrib import learn
@tanayv
tanayv / translation.js
Last active September 12, 2018 01:11
Flattening Promises
const translateSongLyrics = (songLines, callback) => {
let config = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
};
let endpoint = "https://translate.yandex.net/api/v1.5/tr.json/translate?key=" + yandexApiKey;
songLines.forEach((line) => {
@tanayv
tanayv / ngClass.js
Last active September 10, 2018 01:22
Conditional Rendering: Angular & React
/* How I would do it in Angular (For example in x.component.html) */
<div class="nav">
<div class="option" *ngClass={'selected': 'activeView == 0'} (click)="setView(0)">Playback</div>
<div class="option" *ngClass={'selected': 'activeView == 1'} (click)="setView(1)">Lyrics</div>
<div class="option" *ngClass={'selected': 'activeView == 2'} (click)="setView(2)">Translation</div>
</div>
/* How I did it in react */
class Nav extends Component {