This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
this server recognize a person in photos after just seeing a single photo of the person | |
""" | |
import face_recognition | |
import os | |
import pickle | |
from flask import Flask, jsonify, request | |
from requests.exceptions import RequestException, Timeout, ConnectionError | |
from io import BytesIO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Here be dragons | |
This is a basic interpreter | |
a computer program is just text. Compilers and interpreters translate this text for the machine | |
let's say our program is 2 * 7 + 3 | |
1. First step is lexical analysis, a fancy term for tokenizing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django_filters.rest_framework import FilterSet | |
from django_filters import DateFromToRangeFilter | |
from api.models import Record | |
from django_filters.rest_framework import DjangoFilterBackend | |
from rest_framework import filters | |
class CustomFilter(FilterSet): | |
date = DateFromToRangeFilter() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def decodeString(self, s): | |
""" | |
s = "3[a]2[bc]", return "aaabcbc". | |
s = "3[a2[c]]", return "accaccacc". | |
s = "2[abc]3[cd]ef", return "abcabccdcdcdef". | |
""" | |
stack = []; coeff = 0; ans = '' | |
for c in s: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fuzzywuzzy import process, fuzz | |
def match_by_fuzzy_string_search( | |
possible_matches: List[str], string_to_be_searched: str | |
) -> str: | |
scores = dict() | |
for candidate in possible_matches: | |
n = len(candidate.split()) | |
n_grams = generate_ngrams(string_to_be_searched, n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define STACK_MAX 256 | |
typedef enum | |
{ | |
OBJ_INT, | |
OBJ_PAIR | |
} ObjectType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Lispy: Scheme Interpreter in Python | |
Peter Norvig's lis.py studied here | |
http://norvig.com/lispy.html | |
The beauty of Scheme is that the full language only needs 5 keywords and 8 syntactic forms. | |
In comparison, Python has 33 keywords and 110 syntactic forms, | |
and Java has 50 keywords and 133 syntactic forms. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INTEGER | |
BOOLEAN | |
TEXT | |
FLOAT | |
DOUBLE | |
CHARACTER(num_chars) | |
VARCHAR(num_chars) | |
DATE | |
DATETIME | |
BLOB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Machine Learning model to predict the genres of a movie from its summary | |
""" | |
import os | |
import pickle | |
from io import StringIO | |
from flask import Flask, request | |
from sklearn.preprocessing import MultiLabelBinarizer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from flask.json import JSONEncoder | |
import datetime | |
class CustomJSONEncoder(JSONEncoder): | |
"Add support for serializing time" | |
def default(self, o): |