by Angel Leon. March 17, 2015;
Last update on December 14, 2023
Updated on February 27, 2023
Updated August 29, 2019.
| // source: https://msdn.microsoft.com/en-us/library/bb259689.aspx | |
| //------------------------------------------------------------------------------ | |
| // <copyright company="Microsoft"> | |
| // Copyright (c) 2006-2009 Microsoft Corporation. All rights reserved. | |
| // </copyright> | |
| //------------------------------------------------------------------------------ | |
| using System; | |
| using System.Text; |
| #!/usr/bin/env python | |
| import caffe | |
| from caffe.proto import caffe_pb2 | |
| from google.protobuf import text_format | |
| class structtype: | |
| pass | |
| def loadSolver(fn): | |
| with open(fn) as f: |
| # -*- coding: utf-8 -*- | |
| ''' | |
| Ranking code based on: | |
| https://github.com/coleifer/peewee/blob/master/playhouse/sqlite_ext.py | |
| ''' | |
| import struct | |
| import math |
This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.
The script is here:
#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"
| ;; based on http://talks.golang.org/2012/concurrency.slide#50 | |
| (ns robpike | |
| (:require [cljs.core.async :as async :refer [<! >! chan close!]]) | |
| (:require-macros [cljs.core.async.macros :as m :refer [go alt!]])) | |
| (defn timeout [ms] | |
| (let [c (chan)] | |
| (js/setTimeout (fn [] (close! c)) ms) | |
| c)) |
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
The goal of this example is to show how an existing C codebase for numerical computing (here c_code.c) can be wrapped in Cython to be exposed in Python.
The meat of the example is that the data is allocated in C, but exposed in Python without a copy using the PyArray_SimpleNewFromData numpy