- https://www.w3.org/2001/sw/sweo/public/UseCases/FAO/
- presentation on event in 2010
- Yummly food processor
- FOODpedia, linked data for food products
- Semantic web and GS1 (presentation)
- Example of how to use a semantic web of food
- OpenFoodFacts food product ontology notes, you can download a full products RDF dump
- Linked open data for halal food products - nice usage example
import random | |
from itertools import chain, cycle, islice | |
import torch.utils.data as data | |
import matplotlib.pyplot as plt | |
from matplotlib.patches import Rectangle | |
import time | |
import torch | |
import numpy as np |
import bz2 | |
import pickle | |
from django.conf import settings | |
from djang_redis import get_redis_connection | |
from tqdm import tqdm | |
from .constants import GOOGLE_WORD2VEC_MODEL_NAME | |
# File: KnuthMorrisPratt.py | |
# Author: Keith Schwarz ([email protected]) | |
# | |
# An implementation of the Knuth-Morris-Pratt (KMP) string-matching algorithm. | |
# This algorithm takes as input a pattern string P and target string T, then | |
# finds the first occurrence of the string T in the pattern P, doing so in time | |
# O(|P| + |T|). The logic behind the algorithm is not particularly complex, | |
# though getting it to run in linear time requires a few non-obvious tricks. | |
# | |
# To motivate KMP, consider the naive algorithm for trying to match a pattern |
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.
I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.
So below I made a list of leetcode problems that are as close to grokking problems as possible.
# Nathan Lehrer | |
def get_best_path(grid): | |
# Finds the best path through an M x N grid of point values, and that path's score | |
# Input: grid = grid of point values = M x N list of lists | |
# Returns: best_score = best possible score = int, path = best possible path = string | |
M,N = len(grid),len(grid[0]) | |
scores = {(0,0):grid[0][0]} # best score for a path to each cell; score of (0,0) is grid value | |
trace = {} # whether we optimally come from up ('U') or left ('L') into each cell | |
gunicorn run:app --workers=9
gunicorn run:app --workers=9 --worker-class=meinheld.gmeinheld.MeinheldWorker
Macbook Pro 2015 Python 3.7
Framework | Server | Req/s | Max latency | +/- Stdev |
---|