const std = @import("std"); | |
// primitive of the event loop. | |
// Ctx is typically a pointer to *This and data a pointer to the Users data. | |
// destroyData is called after the event has finished and must clean up the event to avoid leaks. | |
const Event = struct { | |
ctx: *anyopaque, | |
data: *anyopaque, | |
name: []const u8, | |
destroyData: *const fn (*anyopaque, *anyopaque) void, |
{ pkgs ? import <nixpkgs> {}, lib ? pkgs.lib, stdenv ? pkgs.stdenv, zig ? pkgs.zig, static ? true, target }: | |
with lib; | |
with builtins; | |
# Zig based cross-compiling toolchain | |
# | |
# Major known issues: | |
# - Zig seems to randomly fail with parallel builds with 'error: unable to build ... CRT file: BuildingLibCObjectFailed' | |
# This seems like race condition with the cache? |
#if 0 // self-compiling code: chmod +x this file and run it like a script | |
BINARY=vaapi_egl_interop_example | |
gcc -std=c99 -Wall -Wextra -pedantic -Werror -g -fsanitize=address -o $BINARY $0 \ | |
`pkg-config libavcodec libavformat libavutil libva gl egl libdrm --cflags --libs` \ | |
-lX11 -lva-x11 -lva-drm || exit 1 | |
test "$1" = "--compile-only" && exit 0 | |
exec env ASAN_OPTIONS=fast_unwind_on_malloc=0 ./$BINARY $* | |
#endif /* | |
Minimal example application for hardware video decoding on Linux and display |
NOTE: The Tree-sitter API and documentation has changed and improved since this guide was created. I can't guarantee this is up to date.
Tree-sitter is the new way Atom is providing language recognition features, such as syntax highlighting, code folding, autocomplete, and more. In contrast to TextMate grammars, which work by regex matching, Tree-sitter will generate an entire syntax tree. But more on that can be found in it's own docs.
Here, we look at making one from scratch.
Markdown Preview Enhanced supports rendering flow charts
, sequence diagrams
, mermaid
, PlantUML
, WaveDrom
, GraphViz
, Vega & Vega-lite
, Ditaa
diagrams.
You can also render TikZ
, Python Matplotlib
, Plotly
and all sorts of other graphs and diagrams by using Code Chunk.
Please note that some diagrams don't work well with file exports such as PDF, pandoc, etc.
This feature is powered by flowchart.js.
import numpy as np | |
import tensorflow as tf | |
__author__ = "Sangwoong Yoon" | |
def np_to_tfrecords(X, Y, file_path_prefix, verbose=True): | |
""" | |
Converts a Numpy array (or two Numpy arrays) into a tfrecord file. | |
For supervised learning, feed training inputs to X and training labels to Y. | |
For unsupervised learning, only feed training inputs to X, and feed None to Y. |
import Html exposing (Html, div, text, program) | |
type alias Model = | |
String | |
init : ( Model, Cmd Msg ) | |
init = | |
( "Hello", Cmd.none ) | |
# | |
# Copyright (c) 2016, Nikolay Polyarnyi | |
# All rights reserved. | |
# | |
import numpy as np | |
def rgb_to_hsv(rgb): | |
""" |
// define a grammar called Hello | |
grammar Hello; | |
r : 'hello' ID; | |
ID : [a-z]+ ; | |
WS : [ \t\r\n]+ -> skip ; |