Implementation doctrine for the age of AI: what to do, and what once-good advice to unlearn, in one document. It distills a study of sixteen expert programmers' philosophies; credit is given by name where a specific idea is owed to a specific person, but this file stands alone. Patterns state the rule and its reasoning. Retired blocks inside them name the old advice the rule replaces — advice that was genuinely right, often for decades, before the ground moved.
This file contains hidden or 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 allows us to read the cities.json file. The format of the file | |
| # is 'Javascript Object Notation' (JSON). It's a way of representing | |
| # essential data structures, like lists and key-value pairs. | |
| import json | |
| # Our data will be in this format: | |
| # { | |
| # "city": "Beloit", |
This file contains hidden or 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
| cmake -DPYTHON_DEFAULT_INTERPRETER=$(which python3) -DBUILD_opencv_python3=ON -DPYTHON3_LIBRARY=/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/libpython3.9.dylib -DPYTHON3_INCLUDE_DIR=/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/include/python3.9 .. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
| diff --git a/src/runtime/opencl.cpp b/src/runtime/opencl.cpp | |
| index 3fb98b4..4b5eca2 100644 | |
| --- a/src/runtime/opencl.cpp | |
| +++ b/src/runtime/opencl.cpp | |
| +} // extern C | |
| + | |
| +#include <map> | |
| +struct kernel_cache_t { bool cached; cl_kernel kernel; inline kernel_cache_t() : cached(false) {} }; | |
| +std::map<const char*, kernel_cache_t> precompiled_kernels; |
Snippets collected/distilled from gists/blog posts/etc. Combined here for fellow web-searchers -- goal is to have an easy/minimal sink for in-app use, and then forward that stream in another process.
Read camera, push to UDP sink (usually from appsrc, here v4l2 camera):
$ gst-launch-1.0 -vvvv v4l2src ! 'video/x-raw, width=640, height=480, framerate=30/1' ! videoconvert ! x264enc pass=qual quantizer=20 tune=zerolatency ! rtph264pay ! udpsink port=1234
Visualize above:
$ gst-launch-1.0 -vvv udpsrc port=1234 ! "application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264" ! rtph264depay ! h264parse ! decodebin ! videoconvert ! xvimagesink sync=false
This file contains hidden or 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
| keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000 | |
| jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore some.apk alias_name |
This file contains hidden or 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
| bazel build tensorflow/tools/graph_transforms:transform_graph | |
| bazel-bin/tensorflow/tools/graph_transforms/transform_graph --in_graph=../models/object_detection/ssd_mobilenet_v1_coco_11_06_2017/frozen_inference_graph.pb --out_graph=transformed_inference_graph.pb --inputs='image_tensor' --outputs='detection_boxes,detection_scores,detection_classes,num_detections' --transforms=' | |
| add_default_attributes | |
| strip_unused_nodes(type=float) | |
| remove_nodes(op=CheckNumerics) | |
| fold_constants(ignore_errors=true) | |
| fold_batch_norms | |
| fold_old_batch_norms | |
| fuse_resize_pad_and_conv | |
| fuse_pad_and_conv |
This file contains hidden or 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
| layer { | |
| name: "Data1" | |
| type: "Data" | |
| top: "Data1" | |
| top: "Data2" | |
| transform_param { | |
| mean_file: "/home/zl499/caffe/examples/cifar10/mean.binaryproto" | |
| } | |
| data_param { | |
| source: "/home/zl499/caffe/examples/cifar10/cifar10_train_lmdb" |
This file contains hidden or 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
| name: "PVANET-lite" | |
| # https://raw.githubusercontent.com/sanghoon/pva-faster-rcnn/master/models/pvanet/lite/original.pt | |
| ################################################################################ | |
| ## Input | |
| ################################################################################ | |
| layer { | |
| name: 'input-data' |
NewerOlder