# This gist shows how to speed up graphene_django by short-cutting the field and type resolution of the returned JSON and | |
# using a bit of caching to avoid having to repeat our discovery/decision process across multiple fields of the same | |
# type. It relies on trusting the developer to always return the correct types and respect non-nullability. | |
# Assumes that: | |
# 1. You're not using async code | |
# 2. You're using graphql_sync_dataloader to solve the N+1 problem | |
# 3. You're not using any graphene middleware other than for authentication | |
# 4. Your resolvers will all respect the schema | |
# 5. See code comments for further limitations |
import torch | |
import torch.nn.functional as F | |
import coremltools as ct | |
from torch import Tensor | |
from torch import nn | |
from typing import Dict | |
from typing import Optional | |
from ane_transformers.reference.layer_norm import LayerNormANE as LayerNormANEBase | |
from coremltools.models.neural_network.quantization_utils import quantize_weights |
import Foundation | |
import AVKit | |
class VideoHelper { | |
static func getThumbnail(from player: AVPlayer, at time: CMTime) -> CGImage? { | |
do { | |
guard let currentItem = player.currentItem else { return nil } | |
let asset = currentItem.asset | |
let imgGenerator = AVAssetImageGenerator(asset: asset) |
A Step-By-Step Guide from Unboxing to Creative Coding
# based on https://github.com/kylerbrown/ezdtw | |
# with modifications to be fully njit-able | |
import numpy as np | |
from numba import njit | |
@njit | |
def sqeuclidean(a, b): | |
return np.sum((a - b)**2) |
The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).
My take-aways are:
-
You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.
-
Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse
A list of useful commands for the FFmpeg command line tool.
Download FFmpeg: https://www.ffmpeg.org/download.html
Full documentation: https://www.ffmpeg.org/ffmpeg.html
import pprint | |
import requests | |
import os | |
from urllib.request import urlopen | |
accessToken = "xxxxxxxxxx" | |
boardId = "0000000000" | |
folderPath = "./images" | |
response = requests.get( |
Orthodox C++ (sometimes referred as C+) is minimal subset of C++ that improves C, but avoids all unnecessary things from so called Modern C++. It's exactly opposite of what Modern C++ suppose to be.