Skip to content

Instantly share code, notes, and snippets.

View tjkhara's full-sized avatar

tjkhara

View GitHub Profile
@tjkhara
tjkhara / LongestCommonSubsequence.java
Last active September 10, 2019 07:12
lcs problem code
public class LongestCommonSubsequence {
public static int getLongestCommonSubsequence(String a, String b) {
int[][] matrix = new int[a.length() + 1][b.length() + 1];
for (int i = 0; i <= a.length(); i++) {
for (int j = 0; j <= b.length(); j++) {
if (i == 0 || j == 0) {
matrix[i][j] = 0;
@tjkhara
tjkhara / EditDistance.java
Created September 11, 2019 07:26
Edit distance java code
public class EditDistance {
/**
* Returns the EditDistance between source and target string
* @param source
* @param target
* @return
*/
public int editDistanceBetween(String source, String target) {
if (source == null || target == null){
@tjkhara
tjkhara / SherlockHolmes.txt
Created September 11, 2019 14:00
For the spell checker project
This file has been truncated, but you can view the full file.
The Project Gutenberg EBook of The Adventures of Sherlock Holmes
by Sir Arthur Conan Doyle
(#15 in our series by Sir Arthur Conan Doyle)
Copyright laws are changing all over the world. Be sure to check the
copyright laws for your country before downloading or redistributing
this or any other Project Gutenberg eBook.
This header should be the first thing seen when viewing this Project
Gutenberg file. Please do not remove it. Do not change or edit the
@tjkhara
tjkhara / SpellChecker.java
Created September 11, 2019 14:01
Spell checker java code
import java.util.*;
import java.io.FileReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SpellChecker {
public static final int EDIT_DISTANCE_THRESHOLD = 1;
@tjkhara
tjkhara / gist:bc5ee98b2b11ee7fc908e164810e8d85
Created September 25, 2020 05:32
flask code not working
# WINDOWS: set OAUTHLIB_INSECURE_TRANSPORT=1
# Macos/linux: export OAUTHLIB_INSECURE_TRANSPORT=1
# https://flask-dance.readthedocs.io/en/latest/quickstarts/google.html
###########################################################################
###########################################################################
# Visit the Google Developers Console at https://console.developers.google.com and
# create a new project. In the “APIs & auth” section, click on “Credentials”, and
# then click the “Create a new Client ID” button. Select “Web Application” for
# the application type, and click the “Configure consent screen” button. Put in
import os
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = 'true'
os.environ['OATHLIB_RELAX_TOKEN_SCOPE'] = 'true'
################################################
from flask import Flask, redirect, url_for, render_template
from flask_dance.contrib.google import make_google_blueprint, google
app = Flask(__name__)
@tjkhara
tjkhara / google-oauth-working-code
Created September 25, 2020 05:41
Google oauth working code with JP flask course
import os
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = 'true'
os.environ['OATHLIB_RELAX_TOKEN_SCOPE'] = 'true'
################################################
from flask import Flask, redirect, url_for, render_template
from flask_dance.contrib.google import make_google_blueprint, google
app = Flask(__name__)
@tjkhara
tjkhara / account.html
Created September 26, 2020 04:35
Flask html template with bootstrap formatting
{% extends "base.html" %}
{% block content %}
<div class="jumbotron">
<div align='center'>
<h1>Welcome to the page for {{ current_user.username }}</h1>
<img align="center" src="{{ url_for('static', filename='profile_pics/'+current_user.profile_image) }}">
</div>
</div>
<div class="container">
<form method="POST">
@tjkhara
tjkhara / map_and_filter.js
Created October 1, 2020 16:12
map and filter examples
let pets = [
{name: "meow", species: "cat", age: 2},
{name: "miles", species: "dog", age: 10},
{name: "gogo", species: "mouse", age: 1},
{name: "popo", species: "dog", age: 1}
]
// x = pets.push({name: "Puppster", species: "dog", age: 4})
// console.log(x)
@tjkhara
tjkhara / test_class_file.py
Created October 18, 2020 16:12
PyTest Setup and Teardown in class
class TestClass:
@classmethod
def setup_class(cls):
print("Setup Testclass")
@classmethod
def teardown_class(cls):
print("Teardown class")